Comments (3)
I just realized how stupid this was remembering that more tuples exist than just Tuple2 and that would break the consistency, sorry!
from jool.
Thanks for your suggestion, @abueide. When I created jOOλ, I had briefly considered what this library did: https://www.javatuples.org
Unit<A> (1 element)
Pair<A,B> (2 elements)
Triplet<A,B,C> (3 elements)
Quartet<A,B,C,D> (4 elements)
Interestingly enough, they named their tuples without indicating the degree as a number, but then still used (zero based, yuck) accessors, like getValue3()
, and, probably as a compromise, didn't number their generic type variables, but named them <A, B, C, D>
.
This just to show you there isn't really a very satisfying solution that fits everyone. Much better than tuples in general would be records (with named attributes). If Java had anonymous types like C#, then we would hardly use tuples at all, which are impractical, regardless if the value is called v2
or second
or whatever. Because a much bettern name for it would be lastName
(for example).
As long as type inference works (with lambdas or var
), it would actually be possible to write things like:
Stream.of("a", "b")
.map(s -> new Object() { String name = s; })
.forEach(o -> System.out.println(o.name));
But we cannot pass around this type between methods, so the utility is almost zero. We did get first class records with Java 14, though, so I have high hopes that the name of tuple attributes will become irrelevant in the future :)
Cheers,
Lukas
from jool.
@lukaseder Thanks for sharing your insight on the problem, Java 14's records does look promising.
from jool.
Related Issues (20)
- A multi-release jar maybe better, if no extra classes for Java 9+ HOT 1
- Add zipWithIndexAndSize() HOT 3
- IllegalStateException on Seq#append after Seq#forEach HOT 9
- Implement shortcut for 0.0 and 1.0 percentile calculations HOT 3
- Add Seq.toMap() with mergeFunction HOT 1
- Add support for PERCENTILE_CONT semantics HOT 6
- Add @param javadoc to Agg methods
- Add Agg.covarianceDouble HOT 1
- Add Agg.correlationDouble()
- Add Predicate<Tuple[N]<T...>> Tuple.predicate(Predicate[N]<T...>) HOT 5
- A strange issue on java 8: consumer isn't being called HOT 1
- Add Gradle build with Error-Prone in addition to maven HOT 3
- Add set of Predicates 0-16 (similar to Function 0-16) HOT 1
- Some interesting additions (Predicates, fixed Javadoc errors, Wrapped/Safe version of Unchecked/Sneaky) HOT 4
- Wrong result for Agg.regrR2Double() HOT 6
- Fix Javadoc errors, Error prone errors and most obvious warnings HOT 9
- Excess type variables in Agg::bitAndInt and Agg::bitAndLong
- Replace <code><pre> by <pre><code> in Javadoc HOT 1
- Release 0.9.15 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jool.