Skip to content

Instantly share code, notes, and snippets.

@nusco
Created September 13, 2010 12:45
Show Gist options
  • Save nusco/577233 to your computer and use it in GitHub Desktop.
Save nusco/577233 to your computer and use it in GitHub Desktop.
Post: The "method_missing()" Chainsaw
class Performer
def method_missing(name, *args)
"The duck will #{name}: #{args[0]}"
end
end
duck = Performer.new
duck.sing("Quacking in the Rain") # => "The duck will sing: Quacking in the Rain"
duck.dance("Swan Lake") # => "The duck will dance: Swan Lake"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment