标签: go
在for循环中使用scanner.Scan()时获取整数迭代器的惯用方法是什么:
i := 0 for scanner.Scan() { nextInt, _ := strconv.Atoi(scanner.Text()) ints[i] = nextInt i++ }
类似这样的事情,其中i在每次迭代时递增:
for i := range scanner.Scan() {...}