Comment by meowface
11 years ago
When dealing with function calls, they're roughly the same.
But how about things like:
g = some_input() # A list with 3 elements
a, b, c = g
Or in Python 3+:
lst = [1, 2, 3, 4]
head, *tail = lst # 1, [2, 3, 4]
*init, last = lst # [1, 2, 3], 4
a, *b, c = lst # 1, [2, 3], 4
You can do that in go with just a few more characters:
I'll grant you, having to specify the indices is slightly more verbose, but it's also a lot more clear... because what happens when g has more or less than 3 elements? In Go it's clear, more is ok, less will get you a panic.
Again, I don't think the magic unpacking is really helping that much... doing it the same way you'd do anything else in Go is slightly more verbose, but it's also not some new syntax you have to figure out either.