stdlib/strings: Fixed behaviour for substring_from, returns an empty string instead...
authorLucas Bajolet <r4pass@hotmail.com>
Fri, 7 Mar 2014 20:02:00 +0000 (15:02 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 25 Mar 2014 19:30:10 +0000 (15:30 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/string.nit

index d416000..cbd6c09 100644 (file)
@@ -169,7 +169,8 @@ abstract class Text
        # As with substring, a `from` index < 0 will be replaced by 0
        fun substring_from(from: Int): SELFTYPE
        do
-               assert from < length
+               if from > self.length then return empty
+               if from < 0 then from = 0
                return substring(from, length - from)
        end