Value Definition
-
val
indicates call-by-valueFor example
val y = square(2)
From now on,
y
is4
, notsquare(2)
. -
def
indicates call-by-name
def loop: Boolean = loop
def x = loop // OK, call-by-name
val y = loop // inifinite loop, call-by-value