stdlib: Char, added functions is_alpha and is_alphanumeric (used for several operatio...
authorLucas BAJOLET <r4pass@r4pass-ubu-laptophp.(none)>
Tue, 5 Mar 2013 22:35:18 +0000 (17:35 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 19 Mar 2013 18:06:49 +0000 (14:06 -0400)
Signed-off-by: Lucas BAJOLET <r4pass@hotmail.com>

lib/standard/string.nit

index b80cb04..ad0beda 100644 (file)
@@ -543,6 +543,19 @@ redef class Char
                return false
        end
 
+       # Returns true if the char is an alpha digit
+       fun is_alpha: Bool
+       do
+               if (self >= 'a' and self <= 'z') or (self >= 'A' and self <= 'Z') then return true
+               return false
+       end
+
+       # Returns true if the char is an alpha or a numeric digit
+       fun is_alphanumeric: Bool
+       do
+               if self.is_numeric or self.is_alpha then return true
+               return false
+       end
 end
 
 redef class Collection[E]