When functions have some parameters defined in them, those function calls expect us to pass arguments while calling. And as we know, we can pass a function literal that gets evaluated at the time of the call or at the time when it is used. Scala supports call by value and call by name for functions. Let's discuss them in detail.
Evaluation strategies
Call by name
Call by name is an evaluation strategy where we substitute the literal at the place from where we call our function. The literal gets evaluated when it first appears and gets called. We can understand this with a simple example. First, let's take our ColorPrinter application and pass a Boolean function literal that checks if the printer is switched on. For...