Created
September 13, 2010 12:45
-
-
Save nusco/577233 to your computer and use it in GitHub Desktop.
Post: The "method_missing()" Chainsaw
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
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