Get the numeric version of self

require: is_numeric

assert "0".to_n == 0
assert "0.0".to_n == 0.0
assert ".12345".to_n == 0.12345
assert "12345".to_n == 12345
assert "".to_n == 0

Property definitions

core :: numeric $ Text :: to_n
	# Get the numeric version of `self`
	#
	# require: `is_numeric`
	#
	# ~~~~
	# assert "0".to_n == 0
	# assert "0.0".to_n == 0.0
	# assert ".12345".to_n == 0.12345
	# assert "12345".to_n == 12345
	# assert "".to_n == 0
	# ~~~~
	fun to_n: Numeric
	do
		if is_empty then return 0
		if chars.has('.') then return to_f
		return to_i
	end
lib/core/numeric.nit:24,2--40,4