Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created December 7, 2010 16:25
Show Gist options
  • Select an option

  • Save tomas-stefano/731991 to your computer and use it in GitHub Desktop.

Select an option

Save tomas-stefano/731991 to your computer and use it in GitHub Desktop.
Delete should delete one element of the array instead of all
class Array
alias :delete_all :delete
undef :delete
def delete(element)
each_with_index do |index, element_of_array|
delete_at(index) if element == element_of_array
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment