Приглашаем посетить
Куприн (kuprin-lit.ru)

Section 11.9.  What to Do with @_

Previous
Table of Contents
Next

11.9. What to Do with @_

In that last example, had there been any additional parameters to the speak method (like how many times, or in what pitch for singing, for example), the parameters would be ignored by the Mouse::speak method. If we want them to be passed uninterpreted to the parent class, we can add it as a parameter:

$class->SUPER::speak(@_);

This invokes the speak method of the parent class, including all the parameters that we've not yet shifted off of our parameter list.

Which one is correct? It depends. If we are writing a class that simply adds to the parent class behavior, it's best to simply pass along arguments we haven't dealt with. However, if we want precise control over the parent class's behavior, we should determine the argument list explicitly and pass it.


Previous
Table of Contents
Next