If I have something like this: ```class Foo { ...
# getting-started
j
If I have something like this:
Copy code
class Foo {
    var number: Int = 0
}
Is it possible to pass a reference to the
number
property to another class so that the other class can reassign it?
m
I believe you can pass a
KMutableProperty1
to a function and get an instance of from
::number
. You can also access the setter from it pass it somewhere as a
Function
.
s
or you pass a lambda around:
Copy code
val foo = Foo()
val setter: (Int)->Unit = { newValue -> foo.number = newValue }
class Bar( val setNumber: (Int)->Unit )
val bar = Bar(setter)