1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

update the Array#from behaviour changes - returns [] if index exceeds array length

This commit is contained in:
Vijay Dev 2011-04-27 22:21:50 +05:30
parent f76dd271c6
commit 089ee31aad

View file

@ -1996,11 +1996,11 @@ Active Support augments the API of arrays to ease certain ways of accessing them
[].to(7) # => []
</ruby>
Similarly, +from+ returns the tail from the element at the passed index on:
Similarly, +from+ returns the tail from the element at the passed index to the end. If the index is greater than the length of the array, it returns an empty array.
<ruby>
%w(a b c d).from(2) # => %w(c d)
%w(a b c d).from(10) # => nil
%w(a b c d).from(10) # => []
[].from(0) # => []
</ruby>