https://kotlinlang.org logo
j

jdemeulenaere

10/15/2019, 11:52 AM
Not sure whether this was already discussed, but it would be nice to be able to overload the comparison operators (<, >=, ==, etc) other than using compareTo (that must return an Int). I would love to have this for a DSL that is used to write some conditions that can be checked only later in the future. I have this
BooleanExpression
object than can be returned by some call, e.g.
myFutureValue.isGreaterThanOrEquals(aStaticValue)
. It would be nice if instead I could write that using
myFutureValue >= aStaticValue
e

elizarov

10/15/2019, 1:44 PM
r

raulraja

10/15/2019, 1:47 PM
@jdemeulenaere Until that makes it to the lang this can also be achieved with compiler plugins. We have an issue for this in which
==
, etc instead of getting wired to the std libs functions such as
EQEQ
which does now it delegates first to typeclass instances for EQ, Order, etc and if it does not find one it delegates to the original ones. https://github.com/arrow-kt/arrow/issues/1633
🤩 1
2 Views