Skip to content

Instantly share code, notes, and snippets.

@kkosuge
Created August 6, 2013 07:09
Show Gist options
  • Save kkosuge/6162704 to your computer and use it in GitHub Desktop.
Save kkosuge/6162704 to your computer and use it in GitHub Desktop.
class Symbol
def method_missing(method_name, *args, &block)
if method_name.to_s.match(/\?\Z/)
self == method_name.to_s[0..-2].to_sym
else
super
end
end
end
animal = :neko
p animal.inu? #=> false
p animal.neko? #=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment