Hi all,
Ruby 1.8.4 and 1.8.5
The docs for String#slice! say, "The forms that take a Fixnum will raise
an IndexError if the value is out of range."
However, I cannot duplicate this behavior. Whenever I try to force an
IndexError, I just get back nil, i.e. the same behavior as String.slice.
irb(main):001:0> VERSION
=> "1.8.4"
irb(main):002:0> s = "hello"
=> "hello"
irb(main):003:0> s.slice!(-5,-99)
=> nil
irb(main):004:0> s
=> "hello"
irb(main):005:0> s.slice!(-5,100)
=> "hello"
irb(main):006:0> s
=> ""
I tried a few other things with no luck. Am I missing the proper test case?
Thanks,
Dan