3 ms·
You would just make the constructor return a possible error if it's not in range, or maybe some specialty constructors that may clamp it into range for you so t
by hombre_fatal 6y ago
You would just make the constructor return a possible error if it's not in range, or maybe some specialty constructors that may clamp it into range for you so they always succeed.
It's the same question of, how can you convert a string to a Regexp type if not all strings are valid Regexps?
- rco8786 6y agoRight, so there's no way to do this: > In other words, the parameter should not be a float, but a more constrained type that allows floats only in [0,1] It's a value check, not a type check.