im a bit confused about kotlin lambda expression. Can not find a proper answer.
In Java i can set a listener with tho parameters like that:
myObject.setListener(new MyListener() {
@Override
public boolean doSmth(int pos, int value) {
switch(..) {
....
}
}
})
With lambda:
myObject.setListener((p1, p2) -> {
switch(..) {
....
}
})
In Kotlin i can do smth like that:
myObject.setListener{p1, p2 -> return@setListener false}
or
myObject.setListener{{p1, p2 ->
if (p1) {
return@setListener true
} else {
return@setListener false
}
}}
But its really ugly. Is there any way to do it easier? Of i can use smth like that:
myObject.setListener{p1, p2 -> myFunc(p1, p2)}
But what if i wanna put my logic into that listener (it could be complex, not just if else return)