In this blog, we will talk about lazy evaluation in Scala. How we can add efficiency to our application?
Efficiency is achieved not just by running things faster, but by avoiding things that shouldn’t be done in the first place.
In functional programming, lazy evaluation means efficiency. Laziness lets us separate the description of an expression from the evaluation of that expression. This gives us a powerful ability—we may choose to describe a “larger” expression than we need, and then evaluate only a portion of it. There are many ways to achieve lazy evaluation in Scala i.e using lazy keyword, views, streams etc.
The fastest operation is the one that doesn’t have to run at all.