Commit 49ecd44c authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2406 from iij/pr_string_slice_bang

Adapt a behavior of String#slice! to other Ruby implementations
parents ba0ddb78 ec04fa7e
......@@ -169,7 +169,7 @@ class String
if arg1 != nil && arg2 != nil
idx = arg1
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]
else
return nil
......
......@@ -218,7 +218,7 @@ assert('String#slice!') do
assert_equal "Foo", a
a = "FooBar"
assert_nil a.slice!(6, 2)
assert_equal "", a.slice!(6, 2)
assert_equal "FooBar", a
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