Skip to content

Instantly share code, notes, and snippets.

@NV
Created March 21, 2010 13:07
Show Gist options
  • Select an option

  • Save NV/339293 to your computer and use it in GitHub Desktop.

Select an option

Save NV/339293 to your computer and use it in GitHub Desktop.
Ruby's anonymous classes
dog = 'Bob'
class << dog
def what
self
end
end
dog.what #'Bob'
''.what #NoMethodError
# Programming Ruby, The Pragmatic Programers (2nd, 2005)
# page 368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment