mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user