spand
09/18/2020, 2:43 PMfoo2
,foo3
?
interface Foo {
fun bar()
}
private val foo: Foo = object : Foo {
override fun bar() {
TODO("Not yet implemented")
}
}
private val foo2: Foo = {}
private val foo3: Foo = Foo {}
Javier
09/18/2020, 2:45 PMfun interface ...{ ... }
streetsofboston
09/18/2020, 2:47 PMfoo3
assignment
The foo2
assignment is invalid.spand
09/18/2020, 2:48 PMspand
09/18/2020, 2:49 PMNir
09/18/2020, 2:59 PMNir
09/18/2020, 3:00 PMNir
09/18/2020, 3:01 PMNir
09/18/2020, 3:02 PMfun interface
anyhow as writing code in Kotlin that's nice to call from both Java and Kotlin.spand
09/18/2020, 4:51 PMNir
09/18/2020, 5:06 PMspand
09/18/2020, 5:12 PMRuckus
09/18/2020, 9:10 PMval x: Runnable = {}
You can only use the shortest version in higher order functions, and that works for both Kotlin and Java.
fun test1(foo: Foo) { ... }
fun test2(x: Runnable) { ... }
test1 { ... } // Works
test2 { ... } // Also works
Nir
09/18/2020, 9:33 PMNir
09/18/2020, 9:34 PMNir
09/18/2020, 9:35 PMRuckus
09/18/2020, 9:35 PMNir
09/18/2020, 9:35 PMNir
09/18/2020, 9:36 PMNir
09/18/2020, 9:36 PM