Re:Google’s Go has some coders raving
by ominous_prime on Thursday May 30, 2013 @11:07AM
(#5792958)
"_" is when you must assign a value, but don't want to use it.
range in the for loop return 2 values (index, value). If you don't want the index, you can assign it to "_" to ignore it.
oh! that's pretty cool.
Re:Google’s Go has some coders raving
by steveklabnik on Thursday May 30, 2013 @02:32PM
(#5794280)
Check your favorite language, it probably has this feature. Ruby, Haskell, tons of them.
It's the "blank identifier", a throw-away variable. See http://golang.org/ref/spec#Blank_identifier
For iterates over a range and returns the index and the value. If you don't use the index the underscore just ignores it.
Re:Google’s Go has some coders raving
by nuttendorfer on Thursday May 30, 2013 @11:05AM
(#5792941)
AFAIK the function returns to values but you only need name in this case, so _ discards that return value.
"for _, "