In the following code, the last line does not compile. I'm not even sure if I like the way the syntax ends up looking, but should it work?!
package test
class Writer {
fun something(v:String) {}
fun set(n:String, v:String) {}
}
fun writer(init:Writer.() -> Unit) {
val w=Writer()
w.init()
}
fun test() {
writer {
something(“hello”)
// aren’t these three equivalent?
this[“name”]=“value” // ok
set(“name”, “value”) // ok
[“name”]=“value” // compile error
}
}
Thanks, Alfie.