CallByValue和CallByName区别
/** * Created by root * Description :CallByValue:进入函数就得先计算实参的值;CallByName:函数体重使用到的时候才计算 */ object CallByValueAndCallByName { def main(args: Array[String]): Unit = { val c = add(1+2,3) println(c) val c1 = add2(1+2,3) println(c1) } def add(x: Int, y: Int): Int = x + y def add2(x: => Int, y: Int) = x + y }