This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.

first

        # Array.first

(from ruby core)
---
    array.first -> object or nil
    array.first(n) -> new_array

---

Returns elements from `self`; does not modify `self`.

When no argument is given, returns the first element:
    a = [:foo, 'bar', 2]
    a.first # => :foo
    a # => [:foo, "bar", 2]

If `self` is empty, returns `nil`.

When non-negative Integer argument `n` is given, returns the first `n`
elements in a new Array:
    a = [:foo, 'bar', 2]
    a.first(2) # => [:foo, "bar"]

If `n >= array.size`, returns all elements:
    a = [:foo, 'bar', 2]
    a.first(50) # => [:foo, "bar", 2]

If `n == 0` returns an new empty Array:
    a = [:foo, 'bar', 2]
    a.first(0) # []

Related: #last.



      

This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.