3 ms·
In addition it removes a lot of boilerplate code with things such as automatic casting. Adds null safety.
by hhariri 13y ago
In addition it removes a lot of boilerplate code with things such as automatic casting. Adds null safety.
- dodyg 13y agoFor me it's the function expansion syntax. fun main(args : Array<String>) { val a = calculate(1) { x -> 10 + x } //11 val b = calculate(2) { x -> 20 * x } //40 println("a = $a, b = $b") } fun calculate(a : Int, calc : (Int) -> Int) : Int{ return calc(a) }