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

last

        # Array.last

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

---

Returns elements from `self`; `self` is not modified.

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

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

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

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

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

Related: #first.



      

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.