scala 函数调用_在Scala中按名称调用函数

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中使用按名称调用 。 在程序中按名称传递作为调用传递的代码块,直到函数调用该代码块后,才能执行。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值