scala 函数调用
函数按名称调用 (Functions call by name )
By default, the method of parameter passing in a programming language is "call by value". In this, the parameter is passed to a function which makes a copy of them an operates on them. In Scala also, the call by name is the default parameter passing method.
默认情况下,以编程语言传递参数的方法是“按值调用” 。 在这种情况下,参数被传递给一个函数,该函数使它们的副本对它们进行操作。 同样在Scala中,按名称调用是默认的参数传递方法。
Call by name is used in Scala when the program needs to pass an expression or a block of code as a parameter to a function. The code block passed as call by name in the program will not get executed until it is called by the function.
当程序需要将表达式或代码块作为参数传递给函数时, 在Scala中使用按名称调用 。 在程序中按名称传递作为调用传递的代码块,直到函数调用该代码块后,才能执行。