And today's #golang wtf goes to: `for i := range make([]struct{}, 10) ...` 😂
@sungo I'd be a bit more forgiving if it were []int, because, maybe it's an honest mistake. But []struct{} implies malice!
@apg Is its goal strictly to iterate to 10 using range because for loops aren't hip? My brain is refusing to understand it, I think.
@sungo `for i := 0; i < 10; i++ {` is certainly more desirable here. No idea why it was written this way. Functionally equivalent, but _way_ more idiotic to involve range.
The reason I suggest []int would have made more sense is, at least you could make the argument that the author thought []int would be initialized as 0, 1, 2, 3, 4... (LOL) but... seems more like carelessness, this way.
@apg []int uses heap memory, []struct{} does not (the struct{} type does not consume any space)
@jrick I understand that. That doesn't make this excusable, though.
@apg agree 100%
@apg was unaware make offered a 2-ary signature
@mcandre it even offers a ternary version for slices!
@apg I.... Wha....