Commit ec04fa7e authored by Akito Mochizuki's avatar Akito Mochizuki

Modify return value of String#slice! if idx == self.size

parent ba0ddb78
...@@ -169,7 +169,7 @@ class String ...@@ -169,7 +169,7 @@ class String
if arg1 != nil && arg2 != nil if arg1 != nil && arg2 != nil
idx = arg1 idx = arg1
idx += self.size if arg1 < 0 idx += self.size if arg1 < 0
if idx >= 0 && idx < self.size && arg2 > 0 if idx >= 0 && idx <= self.size && arg2 > 0
str = self[idx, arg2] str = self[idx, arg2]
else else
return nil return nil
......
...@@ -218,7 +218,7 @@ assert('String#slice!') do ...@@ -218,7 +218,7 @@ assert('String#slice!') do
assert_equal "Foo", a assert_equal "Foo", a
a = "FooBar" a = "FooBar"
assert_nil a.slice!(6, 2) assert_equal "", a.slice!(6, 2)
assert_equal "FooBar", a assert_equal "FooBar", a
a = "FooBar" a = "FooBar"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment