Sha256: d92fbab88116716c53257ba66d3c469a764eb184562c90ba44e84728969122dc

Contents?: true

Size: 369 Bytes

Versions: 2

Compression:

Stored size: 369 Bytes

Contents

unless Array.method_defined? :init
  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 empty array if this
    #   array is empty
    #
    # @example
    #   [1, 2, 3].init #=> [1, 2]
    #   [].init #=> []
    def init
      self[0...-1]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
powerpack-0.0.6 lib/powerpack/array/init.rb
powerpack-0.0.5 lib/powerpack/array/init.rb