Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
# assert "abcd".has_suffix("bcd") == true
fun has_suffix(suffix: String): Bool do return has_substring(suffix, length - suffix.length)
+ # Returns a copy of `self` minus all occurences of `c`
+ #
+ # assert "__init__".remove_all('_') == "init"
+ fun remove_all(c: Char): String do
+ var b = new Buffer
+ for i in chars do if i != c then b.add i
+ return b.to_s
+ end
+
# If `self` contains only digits, return the corresponding integer
#
# assert "123".to_i == 123
end
end
-redef class Text
- private fun remove_underscores: Text do
- var b = new FlatBuffer
- for i in chars do
- if i == '_' then continue
- b.add i
- end
- return b
- end
-end
-
redef class AIntExpr
# The value of the literal int once computed.
var value: nullable Int