Skip to content

Instantly share code, notes, and snippets.

@capoferro
Created November 21, 2012 22:54
Show Gist options
  • Select an option

  • Save capoferro/4128376 to your computer and use it in GitHub Desktop.

Select an option

Save capoferro/4128376 to your computer and use it in GitHub Desktop.
module ArrayExt
def add_element(element, side = :tail)
case side
when :head
unshift element
when :tail
self << element
else
raise ArgumentError.new('argument \'side\' must be one of :head, :tail')
end
end
end
class Array
include ArrayExt
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment