M
Matthew Berg
It appears that if you use slice or slice! with a length argument, it
returns an array even if the index is out of range:
irb(main):001:0> a = []
=> []
irb(main):002:0> b = a.slice(0)
=> nil
irb(main):003:0> b = a.slice(0,1)
=> []
Here's the output of ruby -v:
ruby 1.8.0 (2003-08-04) [i686-linux]
returns an array even if the index is out of range:
irb(main):001:0> a = []
=> []
irb(main):002:0> b = a.slice(0)
=> nil
irb(main):003:0> b = a.slice(0,1)
=> []
Here's the output of ruby -v:
ruby 1.8.0 (2003-08-04) [i686-linux]