Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, it's the same in Kotlin, from the docs:

"There is a convention that if the last parameter to a function is a function, that parameter can be specified outside of the parentheses."

So you can have normal arguments and specify the last parameter outside like.

    val col = "A"
    val row = 3
    table.update(col, row) {
       it * 5
    }
You may have confused that with SAM-conversions (?), which are for java-interop: https://kotlinlang.org/docs/reference/java-interop.html#sam-...


Cool. Learn something new every day. (I was confused because all the examples except for lock() are single-arg, and IntelliJ usually autocompletes with parentheses because there's often a non-functional overload.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: