Last active
August 29, 2015 14:19
-
-
Save lxkm/b3128733a22c5fd37baa to your computer and use it in GitHub Desktop.
Basic "In" method for Ruby, mimicking Python
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
# 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