-
I have something like:
but I wonder if there is a better approach |
Beta Was this translation helpful? Give feedback.
Answered by
Iltotore
Apr 19, 2022
Replies: 1 comment
-
In Iron, Your code is actually ok. You can use Also note that val x: Int = ???
val y: Int / AlwaysValidConstraint = x //No error and no verification required in 2.0.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Iltotore
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Iron,
Raw
meansnot refined
. In other words, it's a value of typeConstrained
value with an always-true constraint (or "no constraint"). It should always beRight
.Your code is actually ok. You can use
getOrElse
to shorten your code but it is mostly a matter of preferences.Also note that
Raw
will probably disappear in 2.0.0. Seamless interoperability between "normal" types and refined/constrained is targeted: