Class: Array

Inherits:
Object show all
Defined in:
lib/inactive_support/array/butlast.rb,
lib/inactive_support/array/butfirst.rb

Instance Method Summary collapse

Instance Method Details

#butfirstObject

Returns the tail of the array



5
6
7
8
9
10
11
# File 'lib/inactive_support/array/butfirst.rb', line 5

def butfirst
  if empty?
    []
  else
    self[1..-1]
  end
end

#butlastObject

Returns all elements excluding the last one



5
6
7
8
9
10
11
# File 'lib/inactive_support/array/butlast.rb', line 5

def butlast
  if empty?
    []
  else
    self[0...-1]
  end
end