refined
refined copied to clipboard
Scala 3.2: Comparing NonNegInt with Int gives a compile error
If I make an equal comparison on a NonNegInt with Int I get a compile error:
def mapSignalStrengthUmts(rcspLev: NonNegInt): Option[Int] =
if rcspLev < 1 then Some(-116) // same as if rcspLev == 0 but this gives a Refined compile error
gives:
Values of types eu.timepit.refined.types.numeric.NonNegInt and Int cannot be compared with == or !=
I believe that's expected, as NonNegInt is a intentionally a separate type. One should use .value to unpack. e.g. if rcspLev.value < 1