为什么是 FunctionN(0

编程入门 行业动态 更新时间:2024-10-26 00:21:42
本文介绍了为什么是 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?

推荐答案

让 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

本文发布于:2023-10-24 08:54:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523498.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为什么是   FunctionN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!