there is some talk here... I totally need them... ...
# announcements
e
there is some talk here... I totally need them... actually I simply want:
Copy code
interface SomethingWithEvents {
    fun Toggled.onSomething(listener: () -> (Unit))
}
To get called like this:
Copy code
fun main(args: Array<String>) {
    (args as Toggled).apply {
        val something = args as SomethingWithEvents
        something.onSomething {
            println("Come on Kotlin for real m8")
        }
    }
}
which would ultimately make a java call like this:
Copy code
something.onSomething(this, () -> {

});
d
Why are you casting an array to interface types?
The function you declared is called an instance extension function. The instance needs to be in scope as a receiver. The function receiver type should be the subject of a dot-qualified expression.
Therefore you would have to do:
Copy code
with(something) { toggled.onSomething { ..
 } }
In the future please try to use more descriptive names
👆 1
e
I'm casting the array because I don't want to include implementations.
Also I'm aware the instance has to be int he scope as a receiver... That's the problem. I can't see why that would be, and I'm wondering if that will be changed going forward.
d