Created
November 2, 2011 18:32
-
-
Save sdeming/1334449 to your computer and use it in GitHub Desktop.
in?
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 Object | |
def in? *others | |
[others].flatten.include? self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
irb(main):037:0> 1.in? [5, 1, 54]
true
irb(main):038:0> self.in? [1,2,3]
false
irb(main):039:0> self.in? [1,2,3,self]
true
irb(main):040:0> "in".in? "in", "not"
true
irb(main):041:0> "in".in? "nin", "not"
false