Skip to content

Instantly share code, notes, and snippets.

@aereal
Created April 17, 2013 05:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/5402082 to your computer and use it in GitHub Desktop.
Save aereal/5402082 to your computer and use it in GitHub Desktop.
module Element
alias_method :near_equal?, :===
def ===(other)
other.respond_to?(:include?) ? other.include?(self) : self.near_equal?(other)
end
end
[String, Symbol, Numeric].each do |elm|
elm.send(:include, Element)
end
case %w(a b c)
when 'a'
puts 'A'
else
puts '>_<'
end # => A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment