Created
June 12, 2014 21:48
-
-
Save matsumonkie/d9065393617d9f808137 to your computer and use it in GitHub Desktop.
singleton object
This file contains 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
# 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