Skip to content

Instantly share code, notes, and snippets.

@timrogers
Created March 19, 2013 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timrogers/5199100 to your computer and use it in GitHub Desktop.
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.
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