class Array
def to(position)
%w( a b c d ).to(-2) # => ["a", "b", "c"]
%w().to(0) # => []
%w( a b c d ).to(10) # => ["a", "b", "c", "d"]
%w( a b c d ).to(2) # => ["a", "b", "c"]
%w( a b c d ).to(0) # => ["a"]
Returns the beginning of the array up to +position+.
def to(position) if position >= 0 take position + 1 else self[0..position] end end