Created
September 14, 2012 17:27
-
-
Save siannopollo/3723370 to your computer and use it in GitHub Desktop.
Anonymous class instantiation
This file contains hidden or 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
thing = Class.new do | |
def boo | |
puts 'ahhh!' | |
end | |
end | |
thing.new.boo # => "ahhh!" | |
# without the variable | |
(Class.new {def hello() puts("hello, dude") end}).new.hello # => "hello, dude" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment