News for hackers. Stuff that matters.
Re:Go Hercule by doragcoder on Friday June 27, 2014 @04:54PM (#7956255)
FYI:

   for i, v := range array
will give you the indexes and values. If you just want the values then use "_" in place of i to "throwaway" the index.

http://play.golang.org/p/JZZ40FMOMz

Re:Go Hercule by axk on Friday June 27, 2014 @05:00PM (#7956283)
The funny thing is that I knew it, but wrote `for v := range array` anyway at least a few times! My point is, it's not very intuitive. Thankfully, the compiler catches that, unless it's `[]int`.
Re:Go Hercule by jnks on Friday June 27, 2014 @05:28PM (#7956371)
The idea is it's `for k := range object` to iterate over the keys, and `for k, v := range object` to iterate over the keys and values, whether the object is a slice, array, map or string. The only exceptional case is a channel, which has no indices/keys.
Re:Go Hercule by axk on Friday June 27, 2014 @05:33PM (#7956391)
It does make perfect sense, just goes against muscle memory from years of Python coding :)