nyxcode
06/02/2017, 3:57 PMalexreidy
06/02/2017, 4:32 PMmoney
property which has a getter and setter function. The setter indirectly sets the money using a Wallet instance. (person.setMoney(99)
calls person.wallet.setMoney(99)
for example.) Wallet in this case is the delegate -- Person delegates money storage to Wallet. Kotlin has a special notion of a delegate: You can alternatively give Wallet special operator functions getValue()
and setValue()
which can make the code a little prettier in some cases: var money: Double by Wallet()
Ruckus
06/02/2017, 4:33 PMnyxcode
06/02/2017, 4:33 PMRuckus
06/02/2017, 4:36 PM