File Manager

Path: /opt/chef.upgrade/embedded/lib/ruby/gems/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/

Viewing File: butlast.rb

unless Array.method_defined? :butlast
  class Array
    # Returns a new array that has all the elements of the current but the last.
    #
    # @return [Array] a new array without the last element or an empty array if this
    #   array is empty
    #
    # @example
    #   [1, 2, 3].butlast #=> [1, 2]
    #   [].butlast #=> []
    def butlast
      self[0...-1]
    end
  end
end