core :: Numeric :: div
/
Numeric
assert 8.div(2) == 4 assert 4.div(0.5) == 8.0 assert 1.1.div(0.1) == 11.0 assert 2.2.div(2) == 1.1
# Universal `/` with any `Numeric` # # ~~~~ # assert 8.div(2) == 4 # assert 4.div(0.5) == 8.0 # assert 1.1.div(0.1) == 11.0 # assert 2.2.div(2) == 1.1 # ~~~~ fun div(other: Numeric): Numeric is abstract
redef fun div(other) do return self / other.to_f
redef fun div(other) do if other isa Float then return to_f / other else if other isa Int then if other == 0 then return self.to_f / 0.0 return self / other else abort end