Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why FunctionN(0-22) ProductN(1-22) TupleN(1-22)?

Tags:

scala

The api has FunctionN(0-22) ProductN(1-22) TupleN(1-22) the question is: 1.why the number is end of 22? why not 21 or 23? 2.why Function is start with 0 ? but Product and Tuple are not?

like image 552
斉日光 Avatar asked Sep 01 '10 12:09

斉日光


1 Answers

It does not make sense to have a Product or a Tuple that contains no elements. These would be equivalent to Unit.

Function0 exists because a function does not necessarily take arguments (e.g. in the case of by-name arguments).

In the case of Tuple22 and Function22 I cannot tell why the Scala team chose 22 as a maximum but it definitely is awkward to have tuples with that many members or functions that take more than 22 arguments.

It could be though that there is a restriction on how many arguments to a method the JVM can handle.

like image 188
Moritz Avatar answered Sep 28 '22 00:09

Moritz