Delegated properties

If you try to break down the words you will see two words, delegate, and property. The name itself says that you delegate something in the form of property. Basically corresponding getValue() and setValue() methods will be called when you try to access any of the variables. They are not backed by class fields, but it delegates works to some other piece of code.

In the following list, we will start to explain a few terms:

  • lazy{}: This is a built-in delegated property method. It will execute lines within the lazy block when a variable, that is, prefs is referenced first. 
  • getValue(): This is responsible for to passing the current state or value of the variable when it is read (when it's on the right side of the = operator). ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.