instance method to

Ruby on Rails 2.3.18

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

to(position)

Returns the beginning of the array up to position.

%w( a b c d ).to(0)  # => %w( a )
%w( a b c d ).to(2)  # => %w( a b c )
%w( a b c d ).to(10) # => %w( a b c d )
%w().to(0)           # => %w()

Parameters

position req
Source
# File activesupport/lib/active_support/core_ext/array/access.rb, line 22
        def to(position)
          self[0..position]
        end

Defined in activesupport/lib/active_support/core_ext/array/access.rb line 22 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::CoreExtensions::Array::Access

Type at least 2 characters to search.

↑↓ navigate · open · esc close