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:
parent
f76dd271c6
commit
089ee31aad
1 changed files with 2 additions and 2 deletions
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue