One Q related to day 13: was there ever a discussi...
# advent-of-code
n
One Q related to day 13: was there ever a discussion of adding support for the spaceship operator <=> for compareTo in Kotlin?
v
Yes, just Google it
n
Searched in youtrack before asking, but yes, should have searched further. Sorry for the noise
v
Don't worry. 🙂
e
you can use
compareTo
as an infix function since Kotlin 1.6: https://youtrack.jetbrains.com/issue/KT-9730
n
yeah, I did that. But I had some code for AoC which contain like 10 calls of compareTo in 25 lines, so thought that <=> would just make it a bit prettier
e
@nkiesel Something is clearly very non-optimal in your code. This kind of code would better be rewritten, new operators will not help here.
n
Code is at https://github.com/nkiesel/AdventOfCode_2022/blob/main/src/test/kotlin/Day13.kt if you want to take a peek. And assuming we would not use the symbols for the override, I have 6 invocations. Most are because I call other compareTo in my compareTo implementations
and yes, my code is clearly non-optimal...