Things that would be good to add in Java are:
- Collection and map literal.
- Value type.
- Multiple return values.
- Destructure.
- Pattern matching.
- Collection and map literal.
- Value type.
- Multiple return values.
- Destructure.
- Pattern matching.
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.