core :: Numeric :: add
+
Numeric
assert 1.add(1) == 2 assert 1.add(0.1) == 1.1 assert 1.1.add(1.1) == 2.2 assert 1.1.add(1) == 2.1
# Universal `+` with any `Numeric` # # ~~~~ # assert 1.add(1) == 2 # assert 1.add(0.1) == 1.1 # assert 1.1.add(1.1) == 2.2 # assert 1.1.add(1) == 2.1 # ~~~~ fun add(other: Numeric): Numeric is abstract
redef fun add(other) do return self + other.to_f
redef fun add(other) do if other isa Float then return to_f + other else return self + other.as(Int) end end