Skip to content

Instantly share code, notes, and snippets.

@sdeming
Created November 2, 2011 18:32
Show Gist options
  • Save sdeming/1334449 to your computer and use it in GitHub Desktop.
Save sdeming/1334449 to your computer and use it in GitHub Desktop.
in?
class Object
def in? *others
[others].flatten.include? self
end
end
@sdeming
Copy link
Author

sdeming commented Nov 2, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment