dart-rational icon indicating copy to clipboard operation
dart-rational copied to clipboard

Accept int (and maybe floats) in operators

Open polux opened this issue 12 years ago • 2 comments

It would be cool if new Rational(1, 1) >= 0 returned true instead of failing. Same for +, -, *, etc.

polux avatar Apr 16 '13 17:04 polux

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) => ...;

a14n avatar Apr 17 '13 22:04 a14n