Skip to content

Instantly share code, notes, and snippets.

@siannopollo
Created September 14, 2012 17:27
Show Gist options
  • Save siannopollo/3723370 to your computer and use it in GitHub Desktop.
Save siannopollo/3723370 to your computer and use it in GitHub Desktop.
Anonymous class instantiation
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