Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 3.2: Comparing NonNegInt with Int gives a compile error #1130

Open
longliveenduro opened this issue Nov 8, 2022 · 1 comment
Open

Comments

@longliveenduro
Copy link

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 !=

@ivan-klass
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants