With kotlin/MPP 1.3.31 `fun foo(block: (Int) ->...
# multiplatform
s
With kotlin/MPP 1.3.31
fun foo(block: (Int) -> Unit) { ... }
in Kotlin would be
func foo(block: (KotlinInt) -> KotlinUnit)
in Swfit, and
foo(Function1<Integer, Unit> block)
in Java. Both require KotlinUnit.Init() (or Unit.INSTANCE) After upgraded to 1.3.40, it can be
func foo(block: (KotlinInt) -> Void)
in Swift, without the KotlinUnit.Init(). Would it possible to omit the Unit.INSTANCE in Java?
g
it possible to omit the Unit.INSTANCE in Java
No, it’s not possible, because Such lambda represented by interface
Function1<in P1, out R>
on JVM, so you cannot declar R as Void.