Why is FunctionN (0-22) ProductN (1-22) TupleN (1-22)?

Api has the function N (0-22) ProductN (1-22) TupleN (1-22) the question is: 1. What is the number - end 22? why not 21 or 23? 2.why function starts at 0? but Product and Tuple are not?

+6
scala
Sep 01 '10 at
source share
1 answer

It makes no sense to have a Product or Tuple that does not contain elements. They would be equivalent to Unit .

Function0 exists because a function does not necessarily accept arguments (for example, in the case of arguments by name).

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

There may be a limit on the number of method arguments the JVM can work with.

+11
Sep 01 '10 at
source share



All Articles