concept Lazy in category kotlin

appears as: Lazy, Lazy
The Joy of Kotlin

This is an excerpt from Manning's book The Joy of Kotlin.

This specific code is only an example of automatically handling closable resources. It’s not of great interest beside this because the lineSequence function returns a Sequence, which is a lazy construct. Lazy means that evaluation (reading the file lines) occurs only later, when the lines are used.

class Lazy {
    operator fun getValue(thisRef: Any?,
                          property: KProperty<*>): Boolean = ...
}

val first: Boolean by Lazy()

The standard Kotlin Lazy interface is, however, slightly more sophisticated. Using this technique, the example that uses functions to implement the Boolean or operator becomes this:

9.10.3 Mapping and flatMapping Lazy

I’m sure you now understand that Lazy is another computational context like List, Option, and Result (and many others that you’ll discover later), and you’re tempted to map and flatMap it!