WhoisAbel / AndroidBasicsInKotlin

In this project, you'll learn the basics of building Android apps with the Kotlin programming language. Along the way, you'll develop a collection of apps to start your journey as an Android developer.
0 stars 0 forks source link

Store data in ViewModel #51

Open WhoisAbel opened 2 years ago

WhoisAbel commented 2 years ago

Property delegation in Kotlin helps you to handoff the getter-setter responsibility to a different class.

This class (called delegate class) provides getter and setter functions of the property and handles its changes.

A delegate property is defined using the by clause and a delegate class instance:

// Syntax for property delegation
var <property-name> : <property-type> by <delegate-class>()
WhoisAbel commented 2 years ago

image