07-20-2023, 04:21 PM
I want to write extension function that modifies "this", for example:
var a = false
a.toggle() // now a contains false
or
var a = 1
a.increment() // now a contains 2
Is it possible in Kotlin?
I can create extension function that returns modified value, but leaves "this" unmodified, but I want even more convenience! It looks like Swift can do that.
var a = false
a.toggle() // now a contains false
or
var a = 1
a.increment() // now a contains 2
Is it possible in Kotlin?
I can create extension function that returns modified value, but leaves "this" unmodified, but I want even more convenience! It looks like Swift can do that.