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

Property definitions

core :: numeric $ Numeric :: add
	# 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
lib/core/numeric.nit:44,2--52,45

core :: numeric $ Float :: add
	redef fun add(other) do return self + other.to_f
lib/core/numeric.nit:125,2--49

core :: numeric $ Int :: add
	redef fun add(other)
	do
		if other isa Float then
			return to_f + other
		else
			return self + other.as(Int)
		end
	end
lib/core/numeric.nit:86,2--93,4