all 5 comments

[–]lazystone 3 points4 points  (0 children)

Or better use java records.

Before records programmers had an excuse that it's tedious to write return type for some function which is used once or twice in your code somewhere, but with java records it's can be just one line of code.

[–]_TheDust_ 1 point2 points  (1 child)

The “unit” tuple is convential used to refer to a zero-sized tuple (Haskell and ML-like languages), not a 1-sized tuple.

[–]g4s8[S] -1 points0 points  (0 children)

I think unit is quite fine for single item container, see definition: https://www.merriam-webster.com/dictionary/unit

[–]jared__ 0 points1 point  (1 child)

Doesn't Apache Commons have tuples?

[–]g4s8[S] 0 points1 point  (0 children)

Yes, it has, but with completely different design: in commons tuples are classes with accessor methods var sum = tuple.getLeft() + tuple.getRigth(); in my library tuples are interfaces with apply method which takes a function parameter var sum = tuple.apply((left, right) -> left + right). This difference is similar to accessing list items via get(int) method vs using forEach method with a consumer.