Re:Why Kotlin is my next programming language (2015)
by Scene_Cast2 on Sunday June 19, 2016 @10:45PM
(#11935797)
I had something like this:
It was not obvious at all that I had to use curly braces. The documentation says:
This is after I figured out that I'm not supposed to use sortWith (I never figured out how to use this one)
[ Parent
| on HN ]
Re:Why Kotlin is my next programming language (2015)
by voddan on Monday June 20, 2016 @01:44AM
(#11936239)
The curly braces are the syntax for lambdas, one of the basic types `(T) -> R?`. There are plenty of examples for using that, but in the respective chapters: https://kotlinlang.org/docs/reference/lambdas.html#higher-or... or in this bunch of examples: https://kotlinlang.org/docs/reference/idioms.html#filtering-...
The docs are arranged in a way that one reads them in the order they are written (at least the first half). I supposed that would take more than half an hour given at the competition.
I don't think Kotlin is the best choice for programming challenges like codeforces - they really don't let him shine (although I use it whenever I can). But if this is a valid case, we can collaborate and write a short tutorial for C/C++ to Kotlin programmers.
Re:Why Kotlin is my next programming language (2015)
by Scene_Cast2 on Monday June 20, 2016 @08:45AM
(#11937583)
Oops, copied the wrong snippet out of the two:
inline fun <T, R : Comparable<R>> Array<out T>.sortBy(
crossinline selector: (T) -> R?) (source)