提交 089ee31a 编写于 作者: V Vijay Dev

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

上级 f76dd271
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册