Created
March 19, 2013 19:03
-
-
Save timrogers/5199100 to your computer and use it in GitHub Desktop.
A monkeypatch for Object in Ruby which is basically the opposite of Array#include?. You can take an any object and call "in?" on it with an array as the parameter, and it will check whether the subject object is in that array.
This file contains 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 Object | |
def in?(array) | |
# Returns true if the Object that this is called on is included in | |
# the array passed in, otherwise returns false | |
array.include? self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment