We write computer program in one or more files. These files are known as source code. When source code is executed and run in memory, it is known as process. Process executes each program statement one by one. Execution of statements is known as evaluation. There are two types of evaluation strategy, eager evaluation and lazy evaluation. Later in this chapter, we will explore and understand types of evaluations. Let's start with eager evaluation.
An expression is executed whenever it comes on the way of program execution. This evaluation strategy is known as eager evaluation, which is also known as strict evaluation. Even the value of expression is not required at the moment the expression is evaluated.
Let us consider the following code:
scala> var fv = 5 fv: Int = 5
We have typed var fv = 5
in console. As it is executed, value 5
is created and bound to variable fv
.
But, this is not the only case. In some conditions, expressions or part...