为什么是 FunctionN(0-22) ProductN(1-22) TupleN(1-22)? [英] why FunctionN(0-22) ProductN(1-22) TupleN(1-22)?

查看:49
本文介绍了为什么是 FunctionN(0-22) ProductN(1-22) TupleN(1-22)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

推荐答案

ProductTuple 不包含任何元素是没有意义的.这些将等同于 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).

Tuple22Function22 的情况下,我不知道为什么 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-22) ProductN(1-22) TupleN(1-22)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆