Created
December 7, 2010 16:25
-
-
Save tomas-stefano/731991 to your computer and use it in GitHub Desktop.
Delete should delete one element of the array instead of all
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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