Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/confer/extensions/array.rb

Instance Method Summary collapse

Instance Method Details

#extract_options!Object

Public: Removes and returns the last element of the Array if it is a Hash.

Examples

array = ["one", "two", {three: 'four'}]
opts  = array.extract_options!
# => {three: 'four'}
array
# => ["one", "two"]

Returns the last element of the Array if it is a Hash, otherwise an empty hash is returned.



17
18
19
20
# File 'lib/confer/extensions/array.rb', line 17

def extract_options!
  return pop if last.is_a?(Hash)
  {}
end