4 ms·
> Not sure why you need (int, bool) when you can have struct{i int, b bool}... You tell me: you for some reason do need (or want) multiple returns. Why, when
by Dewie 12y ago
> Not sure why you need (int, bool) when you can have struct{i int, b bool}...
You tell me: you for some reason do need (or want) multiple returns. Why, when you can just use a struct? ;)
> the tuple you have to access via index, and the struct you access via name... and by name is much more clear in your code.
I guess Go doesn't have destructing (like - `(x, y) := some_fun()`). In that case, I can see how it could be more annoying than the multiple return thing. I do not see, however, how tuples necessitate indexing - in the languages I've used with tuples, the arity is known at compile time, and you have to use certain functions to access the first, second, etc. But if the choice is between multiple returns (which I guess is just two values?) and tuples, then I don't see why the common case (2-arity) can't be easily supported.