- 主题:for loop终于改进了
以前持续用一个变量这个最坑,不小心就掉进去了,这次解决了
Go 1.22 makes two changes to "for" loops.
Previously, the variables declared by a "for" loop were created once and updated by each iteration. In Go 1.22, each iteration of the loop creates new variables, to avoid accidental sharing bugs. The transition support tooling described in the proposal continues to work in the same way it did in Go 1.21.
"For" loops may now range over integers. For example:
package main
import "fmt"
func main() {
for i := range 10 {
fmt.Println(10 - i)
}
fmt.Println("go1.22 has lift-off!")
}
See the spec for details.
Go 1.22 includes a preview of a language change we are considering for a future version of Go: range-over-function iterators. Building with GOEXPERIMENT=rangefunc enables this feature.
--
FROM 43.198.116.*
后面的代码例子跟坑没关系啊
【 在 gpmn 的大作中提到: 】
: 以前持续用一个变量这个最坑,不小心就掉进去了,这次解决了
: Go 1.22 makes two changes to "for" loops.
: Previously, the variables declared by a "for" loop were created once and updated by each iteration. In Go 1.22, each iteration of the loop creates new variables, to avoid accidental sharing bugs. The transition support tooling described in the proposal co
: ...................
--
FROM 114.241.219.*
为什么Golang总能在这种业界共识已久的地方别出心裁挖坑?
【 在 gpmn 的大作中提到: 】
: 以前持续用一个变量这个最坑,不小心就掉进去了,这次解决了
: Go 1.22 makes two changes to "for" loops.
: Previously, the variables declared by a "for" loop were created once and updated by each iteration. In Go 1.22, each iteration of the loop creates new variables, to avoid accidental sharing bugs. The transition support tooling described in the proposal co
: ...................
--
FROM 61.170.180.*
因为他是google
是给g家用,其他都不care
- 来自 水木社区APP v3.5.7
【 在 oldwatch 的大作中提到: 】
: 为什么Golang总能在这种业界共识已久的地方别出心裁挖坑?
--
FROM 120.244.216.*
可为什么现在又改过来了哩
【 在 hothail 的大作中提到: 】
: 因为他是google
: 是给g家用,其他都不care
: - 来自 水木社区APP v3.5.7
: ...................
--
FROM 61.170.180.*
现在google快完蛋了
【 在 oldwatch 的大作中提到: 】
: 可为什么现在又改过来了哩
:
--
FROM 99.105.57.*
跟python的缩进一样,一定要有一两个极其恶心的地方才能让用户记住作者。
【 在 oldwatch 的大作中提到: 】
: 为什么Golang总能在这种业界共识已久的地方别出心裁挖坑?
:
--
FROM 123.113.98.*
噗……无懈可击
【 在 adu 的大作中提到: 】
: 现在google快完蛋了
--
FROM 222.70.18.*