목록Tutorials/Scala (11)
KoreanFoodie's Study
Scala 1 - Call by value vs. Call by name
스칼라에서 call by value와 call by name의 차이를 알아보자 There is two strategy to evaluate values. Call-by-value Evaluate the arguments first, then apply the function to them Call-by-name Just apply the function to its arguments, without evaluating them Let's see the example. def square (x: Int) = x * x [cbv] square(1+1) ~ square(2) ~ 2 * 2 ~ 4 [cbn] square(1+1) ~ (1+1) * (1+1) ~ 2 * (1+1) ~ 2 * 2 ~ 4 So wha..
Tutorials/Scala
2019. 4. 23. 15:37