I would like to be able to have listener below ini...
# announcements
s
I would like to be able to have listener below init
r
Just use a normal class?
Copy code
class A(val p: P) {

    private val listener = MyListener()

    init {
        p.setListener(listener)
    }

    private class MyListener: Listener {
        ...
    }
}
👍 1
s
@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
thanks @ribesg didn't think about it! This works nice!
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
@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
hey @ribesg, yes with inner class it solves all my problems. Thanks again! I've learned something interesting!
👌 1