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:
commit
0c24d352c9
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue