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

Merge pull request #18554 from mechanicles/use-take-method

A little performance improvement using 'take' method over 'first'
This commit is contained in:
Santiago Pastorino 2015-01-17 10:45:43 -02:00
commit 0c24d352c9

View file

@ -21,7 +21,7 @@ class Array
# %w( a b c ).to(-10) # => []
def to(position)
if position >= 0
first position + 1
take position + 1
else
self[0..position]
end