API 有 FunctionN(0-22) ProductN(1-22) TupleN(1-22)问题是:1.为什么数字是22的结尾?为什么不是 21 或 23?2.为什么函数以0开头?但是 Product 和 Tuple 不是?
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?
推荐答案让 Product 或 Tuple 不包含任何元素是没有意义的.这些将等同于 Unit.
It does not make sense to have a Product or a Tuple that contains no elements. These would be equivalent to Unit.
Function0 存在是因为函数不一定接受参数(例如,在按名称参数的情况下).
Function0 exists because a function does not necessarily take arguments (e.g. in the case of by-name arguments).
在 Tuple22 和 Function22 的情况下,我不知道为什么 Scala 团队选择 22 作为最大值,但是拥有这么多成员或函数的元组肯定很尴尬需要超过 22 个参数.
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.
可能对 JVM 可以处理的方法的参数数量有限制.
It could be though that there is a restriction on how many arguments to a method the JVM can handle.
更多推荐
为什么是 FunctionN(0
发布评论