Skip to content

Instantly share code, notes, and snippets.

@178inaba
Last active August 29, 2015 14:26
Show Gist options
  • Save 178inaba/94f8f32ce435a3c5f570 to your computer and use it in GitHub Desktop.
Save 178inaba/94f8f32ce435a3c5f570 to your computer and use it in GitHub Desktop.
go is can not increment the array subscript
package main
import "fmt"
func main() {
var a [10]int
for i := 0; i < 10; {
//a[i++] = 1
a[i] = 1
i++
fmt.Println(a)
}
}
[1 0 0 0 0 0 0 0 0 0]
[1 1 0 0 0 0 0 0 0 0]
[1 1 1 0 0 0 0 0 0 0]
[1 1 1 1 0 0 0 0 0 0]
[1 1 1 1 1 0 0 0 0 0]
[1 1 1 1 1 1 0 0 0 0]
[1 1 1 1 1 1 1 0 0 0]
[1 1 1 1 1 1 1 1 0 0]
[1 1 1 1 1 1 1 1 1 0]
[1 1 1 1 1 1 1 1 1 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment