Comment by NateDad
11 years ago
Can you explain how tuples are significantly different from multiple returns in real programs? You can do
func foo() (string, int, bool) {
return "one", 2, true
}
func bar(s string, i int, b bool) {}
bar(foo())
When dealing with function calls, they're roughly the same.
But how about things like:
Or in Python 3+:
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.