Should math.divide(math.unit("1m"), math.unit("1cm")) return a number, or just a "unitless" Unit? #3502
mrft
started this conversation in
Design decisions
Replies: 1 comment 3 replies
-
|
That is an interesting idea, thanks for bringing this up. For these kind of consistency cases we have a configuration option This will be a breaking change so we need to schedule it for the first next major release. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
math.divide(Unit, somethingElse) returns a Unit in most cases, but a number when the 2 units are compatible.
This makes it hard for the typing system to know which type will be returned, which can lead to annoying type errors.
But apart from the type errors, I am wondering if math.divide shouldn't simply always return a (sometimes unitless) unit (except for when the input were 2 numbers to begin with)?
Beta Was this translation helpful? Give feedback.
All reactions