3 ms·
> for i, v := range someSlice { ... what a ridiculous comment - every single programming language has this or similar syntax for iterating a slice.
by 38 2y ago
> for i, v := range someSlice { ...
what a ridiculous comment - every single programming language has this or similar syntax for iterating a slice.
- TheDong 2y agoAll the languages I can think of that have iteration over a slice also have the ability for users to define iteration over custom collections, such as with generators or whatever... yet the comment I'm replying to is saying custom iterators, something every language has, is too much magic, so clearly "every language has it" isn't enough justification for something not to be magic for them. Anyway, not every language has it. C has arrays, but doesn't have any iteration sugar for them, and the general attitude of gophers does usually seem to be "if C didn't have it, it's not simple, it's magic", and that Go should just be C but with a GC, goroutines, and builtin hashmaps.