Scala's default evaluation strategy is strict. This means that if you don't do anything special, any variable declaration or arguments of a function call are immediately evaluated. The opposite of a strict evaluation strategy is a lazy evaluation strategy, which means that evaluation is performed only when needed.
Strictness and laziness
Strict val
The following is a strict variable declaration:
class StrictDemo { val strictVal = { println("Evaluating strictVal") "Hello" } } val strictDemo = new StrictDemo //Evaluating strictVal //strictDemo: StrictDemo = StrictDemo@32fac009
We can see that println is called immediately. This means that the block at the right side of the assignment...