Skip to content

Instantly share code, notes, and snippets.

@matsumonkie
Created June 12, 2014 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsumonkie/d9065393617d9f808137 to your computer and use it in GitHub Desktop.
Save matsumonkie/d9065393617d9f808137 to your computer and use it in GitHub Desktop.
singleton object
# singleton object are usefull if you
# want an object that is stateless
class << (FERRARI = Object.new)
def to_s
"Ferrari from Maranello"
end
end
case FERRARI
when FERRARI then puts FERRARI # "Ferrari from Maranello"
else puts "something else"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment