class A(val p: P) {
private val listener = MyListener()
init {
p.setListener(listener)
}
private class MyListener: Listener {
...
}
}
👍 1
s
streetsofboston
03/25/2019, 2:34 PM
@standinga Alas, that is not possible. You’’ll have to initialize the vals/vars you use in the
init
above the
init
block itself
s
standinga
03/25/2019, 2:54 PM
thanks @ribesg didn't think about it! This works nice!
standinga
03/25/2019, 4:50 PM
well turns out it works almost nice, because it's problematic with using variables from outer class, need to pass them to inner class and every time I update my call back I need to update constructor etc.
r
ribesg
03/26/2019, 8:55 AM
@standinga could you use an
inner
class instead maybe? I never really used them so I don’t know if that would work
💯 1
s
standinga
03/26/2019, 9:18 AM
hey @ribesg, yes with inner class it solves all my problems. Thanks again! I've learned something interesting!