dart-rational
dart-rational copied to clipboard
Accept int (and maybe floats) in operators
It would be cool if new Rational(1, 1) >= 0 returned true instead of failing. Same for +, -, *, etc.
I am hesitating on this. On one hand it could simplify operations. But on the other hand, it implies to use dynamic as type annotation for argument and skip all static warnings. Thus new Rational(1) + "abc" would produce no warning.
If I could use union type I would do something like that
operator +(int|Decimal other) => ...;