How did "Cow" become an argument when I didn't specify it anywhere?
That's what The Arrow Operator does. From "Method Invocation" in perlobj:
When you call a method, the thing on the left side of the arrow is passed as the first argument to the method. That means when we call Critter->new(), the new() method receives the string "Critter" as its first argument. When we call $fred->speak(), the $fred variable is passed as the first argument to speak().
In reply to Re: Trying to understand method calling in OOP
by haukex
in thread [SOLVED]: Trying to understand method calling in OOP
by Perl300
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |