看到了最新的1.3版本,就算param 传了多于23个,也还是能运行的

来源:3-3 Lambda表达式

轻风融雪

2019-06-27

RT

写回答

1回答

bennyhuo

2019-06-27

说得对,1.3 新增了一个类来支持大于22的情况:

/**
 * A function that takes N >= 23 arguments.
 *
 * This interface must only be used in Java sources to reference a Kotlin function type with more than 22 arguments.
 */
@SinceKotlin("1.3")
interface FunctionN<out R> : Function<R>, FunctionBase<R> {
    /**
     * Invokes the function with the specified arguments.
     *
     * Must **throw exception** if the length of passed [args] is not equal to the parameter count returned by [arity].
     *
     * @param args arguments to the function
     */
    operator fun invoke(vararg args: Any?): R

    /**
     * Returns the number of arguments that must be passed to this function.
     */
    override val arity: Int
}


0
0

Android首选开发语言Kotlin入门与进阶

Google I/O大会钦定Android一级开发语言,现在不学,等待何时

3122 学习 · 387 问题

查看课程