123

scala中的传名调用 | 一根笨茄子

 6 years ago
source link: http://blog.guoyb.com/2018/01/21/scala-call-by-name/?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
scala函数调用的参数传递有两种方式: 一种是传值调用,这种方式和C语言的函数参数传递方式类似,在函数调用的时刻,计算各个参数的值,然后传递进入函数内部,scala中写作function(x: Int); 一种是传名调用,这种调用方式在函数调用时并不直接计算参数的具体值,而是在函数中使用到该参数时,才进行计算,scala中写作function(x: =>Int)。这里有意思的地

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK