hi guys ! interface SAMListener { public v...
# announcements
n
hi guys ! interface SAMListener { public void listen(param1: Object, param2: Object) } myclass.setSAMListener { param1, (param2 as Boolean) -> } I’m trying to make param2 autocast to Boolean, but it’s not working... Is there any way to do it in the prototype of the lambda ?
m
nitrog42: Does this really have to be in the method signature? Why not cast it in the body?
n
well i like the easy way 🙂
I mean cast is ok but require one more line, and param2 will always be a Boolean
m
It doesn't require one more line.
Copy code
myclass.setSAMListener {
  param1, param2 -> param2 as Boolean; !param2
}
n
yes but it’s not as fluent, I need to reuse param2, instead of driectly saying “i have param1 and param2 which is a boolean”
it’s not possible, but I hope in the future we can do things like that
m
Well... I hope not. 🙂
👍 1
There is no point in intruducing complexity to language for such rare usecases.