Hello guys, given Java interface `interface Foo { ...
# announcements
a
Hello guys, given Java interface
interface Foo { int bar(); }
why do I need an explicit labeled return in Kotlin when using SAM conversion when creating a property - instance of this interface:
val foo = Foo { return@Foo 5}
why cannot I just write:
val foo = Foo { return 5 }
I know that I can just write it as
val foo = Foo { 5 }
, but I wonder why I need the labeled return in the second example
r
arkadiy: This is a statement not expression.
arkadiy: that's why, they need to @ to return a value, you can omit it
a
@radityagumay Could you elaborate more, please?