that multiple return values got me interested. I can see this exploding complexity/unreadability of the code at first glance.
honest question - what would be real added value compared to dedicated wrapper type holding all you need for return?
honest question - what would be real added value compared to dedicated wrapper type holding all you need for return?
2. Tuples support pattern matching.
3. For simple cases the return type is clearer, no need to dig up another class declartion to figure out what the field types are.
(int, float, float) calcPosition(...) {
...
return (type, x, y);
}
var (type, x, y) = calcPosition(...);
if (type)
move(x, y);
or var (int type, float x, float y) = calcPosition(...);
I would prefer the first case with automatic type inference.