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
Dico
11/05/2019, 1:43 PM
Why are you casting an array to interface types?
Dico
11/05/2019, 1:44 PM
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.
Dico
11/05/2019, 1:45 PM
Therefore you would have to do:
Copy code
with(something) { toggled.onSomething { ..
} }
Dico
11/05/2019, 1:46 PM
In the future please try to use more descriptive names
👆 1
e
Exerosis
11/05/2019, 1:51 PM
I'm casting the array because I don't want to include implementations.
Exerosis
11/05/2019, 1:52 PM
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.