Let String#slice! return nil (#3533)

Returns `nil` instead of an empty string when non-integer number is given (to make it 2.7 compatible).
This commit is contained in:
Soutaro Matsumoto 2020-09-11 14:34:10 +09:00 committed by GitHub
parent 0d78390bfb
commit f0ddbd502c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2020-09-11 14:34:35 +09:00
Merged-By: soutaro <matsumoto@soutaro.com>
2 changed files with 6 additions and 1 deletions

View file

@ -1588,8 +1588,10 @@ CODE
a = S("FooBar")
if @aref_slicebang_silent
assert_nil( a.slice!(6) )
assert_nil( a.slice!(6r) )
else
assert_raise(IndexError) { a.slice!(6) }
assert_raise(IndexError) { a.slice!(6r) }
end
assert_equal(S("FooBar"), a)