1 Star 0 Fork 0

c01dface/s-go-example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
for.go 748 Bytes
一键复制 编辑 原始数据 按行查看 历史
c01dface 提交于 2024-11-04 18:41 . add for.go
package main
import "fmt"
func main() {
// the most basic type, with a single condition
i := 1
for i <= 3 {
fmt.Println(i)
i = i + 1
}
fmt.Println()
// A classic initial/condition/after for loop
for j := 0; j < 3; j++ {
fmt.Println(j)
}
fmt.Println()
// Another way of accomplishing the basic "do this N times"
// iteration is range over an integer
for i := range 3 {
fmt.Println("range", i)
}
fmt.Println()
// for without a condition will loop repeatedly until you break
// out of the loop or return from the enclosing function
for {
fmt.Println("loop")
break
}
fmt.Println()
// you can also continue to the next iteration of the loop
for n := range 6 {
if n%2 == 0 {
continue
}
fmt.Println(n)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vmalloc/s-go-example.git
git@gitee.com:vmalloc/s-go-example.git
vmalloc
s-go-example
s-go-example
master

搜索帮助