3 ms·
Scala has Tuples, so you can declare: val t = ("hello", 42) You guys should love this! It makes something Java-compatible (a Tuple2<String, Integer>), wh
by fizx 14y ago
Scala has Tuples, so you can declare:
val t = ("hello", 42)
You guys should love this! It makes something Java-compatible (a Tuple2<String, Integer>), while being a bazillion times less verbose.
The price for doing this in the JVM with reasonable Java-compatibility is that Tuple2<A,B> is a different class than Tuple3<A,B,C> than Tuple4<A,B,C,D>. Tuple goes to 22.
Collections-like frameworks dealing with Tuples often have to generate versions of methods that operate on one of each version of tuple, which is why you see 22 methods here, one to generate each version.
As much as I think scala is a little kitchen sink already, and macros are yet another feature I don't think people need in scala, they'd be useful to generate this code pattern.