turansky
04/09/2017, 3:59 PMinit function type.
fun main(args: Array<String>) {
creator("C") {
step("a")
step("b")
}
}
fun creator(id: String, init: Creator.(String) -> Unit): Creator {
val c = Creator(id)
c.init(id)
return c
}
class Creator(private val id: String) {
init {
println("Init creator $id")
}
fun step(id: String) {
println("Creator ${this.id}, Step $id")
}
}
Is it possible to use such behaviour? Or it is a compiler bug?
http://try.kotlinlang.org/#/UserProjects/ervakeekdml7mvu595iqbuautr/bn7iou7oml7qdr36hkpscsnlkg