The Kotlin web demo contains an example where a static function is referred by a double colon (Callable references / reference to a function): ::isOdd
I however cannot find any mention to this in the docs. When creating a Swing application, I can write:
button.addActionListener { (e) -> buttonClick() };
Which is really nice. I have these two methods:
fun buttonClick() = System.out.println(“hello world”);
fun buttonClick2(e : ActionEvent) = System.out.println(“xx”);
It’d be even nicer for me if I could just write something like:
This does not compile, but if I just write “::buttonClick” or “::buttonClick2”, it compiles but the event handler is not invoked.
Am I trying to do something I should not?
Thanks in advance.