dmitry.petrov
04/05/2016, 7:05 AMfun id
is an instance method in Foo. There are no "class methods" in Kotlin.
With bound method references (planned for 1.1) the code above will work with fun id
defined in companion object of Foo and referenced as Foo::id
.
With 1.0:
fun id(x: Int): Int = x
class Foo {
fun call() {
arrayOf(1, 2, 3).map(::id) // ok
arrayOf(1, 2, 3).map { id(it) } // ok
}
}