Sha256: bad9e70b1b561129f98a630c1781987e40390047a2ceac7c9379afa978389adf

Contents?: true

Size: 350 Bytes

Versions: 3

Compression:

Stored size: 350 Bytes

Contents

unless Array.method_defined? :tail
  class Array
    # Returns a new array rejecting the current one's first element.
    #
    # @return [Array] a new array without the first element or nil if this
    #   array is empty
    #
    # @example
    #   [1, 2, 3].tail #=> [2, 3]
    #   [].tail #=> nil
    def tail
      self[1..-1]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
powerpack-0.0.7 lib/powerpack/array/tail.rb
powerpack-0.0.6 lib/powerpack/array/tail.rb
powerpack-0.0.5 lib/powerpack/array/tail.rb