Skip to content

for 循环

https://gobyexample-cn.github.io/for

不带条件的 for 就是 go 的 while

go
	i := 1
	for i <= 3 {
		fmt.Println(i)
		i = i + 1
	}

    for {
		fmt.Println("loop")
		break
	}
go
	for j := 7; j <= 9; j++ {
		fmt.Println(j)
	}
    
	for n := 0; n <= 5; n++ {
		if n%2 == 0 {
			continue
		}
		fmt.Println(n)
	}