re: Because arrays can only be of one type. So you couldn’t return an int and a string for instance. type ReturnValue [2]interface{}
 

You keep bringing up interface as if it's some kind of amazing criticism of Go but as others have said

It's discouraged to be used. Only use it if the type system isn't expressive enough for what you're doing.

Every statically typed language I know of has an equivalent of it. For instance Scala has Any

What interface does is lose type safety and makes the function less clear as to what you should pass in. It loses the benefit of static typing. Which in other comments you seem to say isn't great anyway? If you don't like type safety and enjoy all functions taking any type like this, stick with your dynamic languages

The above is the answer to the wrong statement “you couldn’t return an int and a string for instance.” I am pretty sure it’s exactly what return foo, bar, baz does under the hood. That said, I was correct saying arrays are a perfect fit instead of redundant multiple returns.

stick with your dynamic languages

I do not need advises on what am I to stick to. I am just pointing out to the design flaws of an extremely overvalued inconsistent language.

code of conduct - report abuse