https://kotlinlang.org logo
#announcements
Title
# announcements
t

Travis Griggs

10/30/2019, 6:31 PM
I’m tired of being told that I can’t compare
someByte == 13u
. Is it possible to implement an unbalanced equals override that will let me compare these without having to put toUByte() or toUInt() in everywhere. I tried something like: fun UInt.equals(b:UByte) : Boolean { return this == b.toUInt() } (and the reverse as well) But == sites still complain
d

devbridie

10/30/2019, 6:55 PM
infix fun UByte.eq(other: UInt) = toUInt() == other
k

karelpeeters

10/30/2019, 9:31 PM
t

Travis Griggs

10/31/2019, 4:31 AM
Dereck, with your suggestion, I’d need to evaluate not
someByte == 13u
, but rather
someByte eq 13u
. Is that correct?
👌 1