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

[core] Add numeric.PosInt #9

Closed
kevin-lee opened this issue Apr 26, 2023 · 0 comments · Fixed by #15
Closed

[core] Add numeric.PosInt #9

kevin-lee opened this issue Apr 26, 2023 · 0 comments · Fixed by #15
Assignees
Labels
Milestone

Comments

@kevin-lee
Copy link
Owner

kevin-lee commented Apr 26, 2023

Summary

[core] Add numeric.PosInt

Version

unreleased

Description

PosInt(1) // compiles
PosInt(0) // compile-time error
PosInt(-1) // compile-time error

PosInt.from(123)
// Either[String, PosInt] = Right(PosInt(123))

PosInt.from(-123)
// Either[String, PosInt] = Left(Invalid value: -123. It must be a positive Int)

PosInt.unsafeFrom(999)
// PosInt = PosInt(999)

PosInt.unsafeFrom(-999)
// IllegalArgumentException(Invalid value: -999. It must be a positive Int) is thrown
@kevin-lee kevin-lee added the task label Apr 26, 2023
@kevin-lee kevin-lee added this to the m1 milestone Apr 26, 2023
@kevin-lee kevin-lee self-assigned this Apr 26, 2023
kevin-lee added a commit that referenced this issue Apr 28, 2023
kevin-lee added a commit that referenced this issue Apr 28, 2023
kevin-lee added a commit that referenced this issue Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant