Merge pull request #2406 from iij/pr_string_slice_bang

Adapt a behavior of String#slice! to other Ruby implementations
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-06-19 19:17:24 +09:00
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"