Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

《基本流程控制语法》文章中 for 循环示例错误 #92

Closed
jugggao opened this issue Feb 13, 2021 · 1 comment
Closed

《基本流程控制语法》文章中 for 循环示例错误 #92

jugggao opened this issue Feb 13, 2021 · 1 comment

Comments

@jugggao
Copy link

jugggao commented Feb 13, 2021

一条break语句可以用来提前跳出包含此break语句的最内层for循环。 下面这段代码同样逐行打印出09十个数字。

i := 0
for {
	if i >= 10 {
		break
	}
	i++
	fmt.Println(i)
}

此程序将打印出 110

英文版本中没有后面一句,但是中文版本应改为:

i := 0
for {
	if i >= 10 {
		break
	}
	fmt.Println(i)
	i++
}

最后,万分感谢作者,此书风格是我最喜欢的技术文章风格。

@go101
Copy link
Collaborator

go101 commented Feb 13, 2021

多谢这个发现!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants