I checked the language specification - is there an easier way to say this:
for _, month := range []int{4,6,9,11} {
fmt.Print(month, " ")
}
I (ideally) looked for something like (I know this is not Go)
for month in [4,6,9,11] {
fmt.Print(month, " ")
}
I know that I can:
days30 := []int{4,6,9,11}
for i := range days30 {
fmt.Print(days30[i], " ")
}
But this is less readable ...
Note. This is for learning — so I’m looking for a simple stand-alone solution for students — nothing too advanced.
AndyS source
share