mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
avoid creating range objects
This commit is contained in:
parent
eb3f81f9dc
commit
96525d632d
1 changed files with 1 additions and 1 deletions
|
@ -16,7 +16,7 @@ class Array
|
|||
# %w( a b c d ).to(10) # => %w( a b c d )
|
||||
# %w().to(0) # => %w()
|
||||
def to(position)
|
||||
self[0..position]
|
||||
self.first position + 1
|
||||
end
|
||||
|
||||
# Equal to <tt>self[1]</tt>.
|
||||
|
|
Loading…
Reference in a new issue