Respond to an unknown method call: Difference between revisions

Content added Content deleted
(Undo curly-to-straight quotes in revision 40792 by Spoon! (Talk) — assuming it was accidental since not mentioned in the edit summary)
Line 98: Line 98:
my $example = Example->new;
my $example = Example->new;


$example->foo; # prints "this is foo"
$example->foo; # prints “this is foo”
$example->bar; # prints "this is bar"
$example->bar; # prints “this is bar”
$example->grill; # prints "tried to handle unknown method Example::grill"
$example->grill; # prints “tried to handle unknown method Example::grill”
$example->ding("dong"); # prints "tried to handle unknown method Example::ding"
$example->ding("dong"); # prints “tried to handle unknown method Example::ding”
# prints "it had arguments: dong"
# prints “it had arguments: dong”
# prints "tried to handle unknown method Example::DESTROY" <- I don't know why it does this</lang>
# prints “tried to handle unknown method Example::DESTROY” <- I don't know why it does this</lang>


=={{header|PHP}}==
=={{header|PHP}}==
Line 146: Line 146:
example = Example()
example = Example()


example.foo() # prints "this is foo"
example.foo() # prints “this is foo”
example.bar() # prints "this is bar"
example.bar() # prints “this is bar”
example.grill() # prints "tried to handle unknown method grill"
example.grill() # prints “tried to handle unknown method grill”
example.ding("dong") # prints "tried to handle unknown method ding"
example.ding("dong") # prints “tried to handle unknown method ding”
# prints "it had arguments: ('dong',)"</lang>
# prints “it had arguments: ('dong',)</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==
Line 170: Line 170:
example = Example.new
example = Example.new


example.foo # prints "this is foo"
example.foo # prints “this is foo”
example.bar # prints "this is bar"
example.bar # prints “this is bar”
example.grill # prints "tried to handle unknown method grill"
example.grill # prints “tried to handle unknown method grill”
example.ding("dong") # prints "tried to handle unknown method ding"
example.ding("dong") # prints “tried to handle unknown method ding”
# prints "it had arguments: ["dong"]"</lang>
# prints “it had arguments: ["dong"]</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==