3 ms·
For #2, the "if len(a) == 0" clause is totally non-sense. I hope Go supports "append(nil, data[:2]...)", which will make code much cleaner.
by tapirl 9y ago
For #2, the "if len(a) == 0" clause is totally non-sense.
I hope Go supports "append(nil, data[:2]...)", which will make code much cleaner.
- smnscu 9y agoNot sure what you mean but it seems to work for me https://play.golang.org/p/U9Uuy-_sdjn https://play.golang.org/p/U9Uuy-_sdjn
- tapirl 9y ago"[]string(nil)" is more verbose than "nil".
- AnIdiotOnTheNet 9y agoSeriously? That's your problem with this construct that otherwise does exactly what you asked for?
- tapirl 9y agoIt is easy for compilers to deduce the type of the nil in "append(nil, data[:2]...)".
- AnIdiotOnTheNet 9y agoSure, and it might just in a future version of the spec if there isn't a good reasoning for not doing that. Doesn't mean that "it's more characters!" isn't still a really silly complaint.