I am new to scala, but I have background in javascript.
While I see the need to separate between val
and var
(mutable and immutable), I can't see why the def
statement should ever be needed.
If functions are truly first-class citizens, as in javascript, why should they be declared with def
and not with val
?
Is that design decision based on JVM related constraints, or is there some underlying logic that I fail to comprehend ?