3 ms·
Things that would be good to add in Java are: - Collection and map literal. - Value type. - Multiple return values. - Destructure. - Pattern matching.
by ww520 11y ago
Things that would be good to add in Java are:
- Collection and map literal.
- Value type.
- Multiple return values.
- Destructure.
- Pattern matching.
- saiya-jin 11y agothat 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?
- jinst8gmi 11y ago1. Not having to declare a pointless wrapper class. 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.
- ww520 11y agoIt actually makes the code concise and clearer. e.g. (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.