%w( a b c d ).to(0)# => ["a"]%w( a b c d ).to(2)# => ["a", "b", "c"]%w( a b c d ).to(10)# => ["a", "b", "c", "d"]%w().to(0)# => []%w( a b c d ).to(-2)# => ["a", "b", "c"]%w( a b c ).to(-10)# => []
# File activesupport/lib/active_support/core_ext/array/access.rb, line 24
def to(position)
if position >= 0
take position + 1
else
self[0..position]
end
end