Sha256: ebeaf95a64719941b825bfd47bf6c63582ecdbfc248eabd963060976eb991b6b

Contents?: true

Size: 384 Bytes

Versions: 24

Compression:

Stored size: 384 Bytes

Contents

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

Version data entries

24 entries across 21 versions & 6 rubygems

Version Path
powerpack-0.1.3 lib/powerpack/array/butlast.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/powerpack-0.1.2/lib/powerpack/array/butlast.rb
powerpack-0.1.2 lib/powerpack/array/butlast.rb
dirwatch-0.0.6 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
dirwatch-0.0.5 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
dirwatch-0.0.4 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
dirwatch-0.0.3 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
dirwatch-0.0.2 vendor/bundle/ruby/2.3.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/powerpack-0.1.1/lib/powerpack/array/butlast.rb
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/powerpack-0.0.9/lib/powerpack/array/butlast.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/powerpack-0.0.9/lib/powerpack/array/butlast.rb
powerpack-0.1.1 lib/powerpack/array/butlast.rb