Consider the problem of computing deltas between entries in a stream of events. Each event is paired with the previous value and delivered to a derived implementation. This requires an initial value to be paired with initial value, what might be called the zero.
This works fine, but looks a little odd. The zero is a constant, which one might expect to be defined using a val. Changing def zero to val zero compiles (Scala permits abstract vals) but the run-time value is actually null.
Changing the definition to be lazy, i.e. lazy val zero = "" , restores the desired behavior. The underlying implementation of lazy is obviously rather similar to def, being executed on first reference to the name.