String truncateFloats(Number<out Anything> num) {
switch (num)
case (is Integral<out Anything>) {
return num.string;
}
case (is Float) {
return Float.format(num, 0, 2);
}
case (is Decimal) {
return truncateFloats(num.float);
}
else {
throw AssertionError("Unhandled Number type `` typeOf(num)``");
}
}
If I pass it a Float or a Decimal, it works fine; if I pass in an Integer or a Whole, it reaches the "else" case and throws. This only happens on the Java backend; when I tried a simplified version (no Decimal case and without trying to test Whole) on try.ceylon-lang.org, it worked fine.
ceylon --version reports ceylon version 1.3.3 0d594b3 (Contents May Differ); if it matters, this is on Mac OS Sierra, and Ceylon was installed via Homebrew.
I have a method like this one:
If I pass it a Float or a Decimal, it works fine; if I pass in an Integer or a Whole, it reaches the "else" case and throws. This only happens on the Java backend; when I tried a simplified version (no Decimal case and without trying to test Whole) on try.ceylon-lang.org, it worked fine.
ceylon --version
reportsceylon version 1.3.3 0d594b3 (Contents May Differ)
; if it matters, this is on Mac OS Sierra, and Ceylon was installed via Homebrew.