From f57a9b92d21107a134b883f0b9359e2771814ccd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 29 Dec 2015 13:51:27 -0500 Subject: [PATCH] lib/core: `is_numeric` returns false on empty strings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/core/text/abstract_text.nit | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/text/abstract_text.nit b/lib/core/text/abstract_text.nit index e201e0c..401f32c 100644 --- a/lib/core/text/abstract_text.nit +++ b/lib/core/text/abstract_text.nit @@ -305,7 +305,7 @@ abstract class Text end end - # Returns `true` if the string contains only Numeric values (and one "," or one "." character) + # Is this string in a valid numeric format compatible with `to_f`? # # assert "123".is_numeric == true # assert "1.2".is_numeric == true @@ -313,6 +313,7 @@ abstract class Text # assert "1,2".is_numeric == true # assert "-1.23e-2".is_numeric == true # assert "1..2".is_numeric == false + # assert "".is_numeric == false fun is_numeric: Bool do var has_point_or_comma = false @@ -330,7 +331,7 @@ abstract class Text end end end - return true + return not is_empty end # Returns `true` if the string contains only Hex chars -- 1.7.9.5