Skip to content

Instantly share code, notes, and snippets.

@lxkm
Last active August 29, 2015 14:19
Show Gist options
  • Save lxkm/b3128733a22c5fd37baa to your computer and use it in GitHub Desktop.
Save lxkm/b3128733a22c5fd37baa to your computer and use it in GitHub Desktop.
Basic "In" method for Ruby, mimicking Python
# Probably re-inventing the wheel for the umpteenth time, but figured I'd roll my own basic version.
# Probably also not production-code worthy, but serves well enough for the work I'm doing.
class Object
def in(*other)
raise(ArgumentError,"Other must be an enumberable type") unless other.is_a? Enumerable
other.include? self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment