What is the largest Tuple that Scala supports?
Explanation
Functions and tuples are rewritten as objects by the compiler, and only Function0 through Function22 and Tuple0 through Tuple22 are defined. I think the limit of 22 is entirely arbitrary, but the reason for having a limit is not.
Think of it this way: to run a Scala application the classes needed to run it must be present. If the compiler would dynamically create classes for functions then those classes would not be included in the Scala library JAR, so you would have to include them in your application. That could work, but then you would have the problem of what the classes' fully qualified names should be: if they were the same for all apps then you would have clashes since libraries would contain the same classes, and if the names were not the same you would end up with incompatibilities -- functions from libraries wouldn't be the same as functions in your app.
Read more: Stackoverflow: Why are scala functions limited to 22 parameters?

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback