-
-
Save siassaj/618e3230f713fb1fc26d to your computer and use it in GitHub Desktop.
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
# something like | |
a_special_object = Object.new do | |
class << self | |
def make_noise | |
"noise!" | |
end | |
end | |
end | |
# instead of | |
another_special_object = Object.new | |
def another_special_object.say_hi | |
"hi" | |
end | |
# although this works and is not so bad | |
a_third_special_object = Object.new.tap do |o| | |
def o.make_noise | |
"noise!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment