First of all… I’ve been using Kotlin for sometime now, and I find it to be like Java++. Thank you for creating it!
Now…
I really like that you can easily pass these anonymous blocks to functions, like this:
``
class Foo {
fun doSomethingWith(whatever: Whatever, callback: () -> Unit) {
// do stuff
// …
// callback()
}
}
Foo().doSomethingWith(whatever, {
println("done!")
})
I find that I use this quite often… but the only thing that bothers me, is the syntax of the block definition: “callback: () -> Unit”.
I find this a bit hard to remember and too verbose, because of the type declaration.
Is there no way to simply leave the “-> Unit” out? Or perhaps there already is a simpler way to achieve what I want?
Thanks.