in reply to [SOLVED]: Trying to understand method calling in OOP
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().
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Trying to understand method calling in OOP
by Anonymous Monk on May 07, 2018 at 21:48 UTC | |
by Your Mother (Archbishop) on May 07, 2018 at 22:17 UTC | |
by stevieb (Canon) on May 07, 2018 at 22:19 UTC | |
by karlgoethebier (Abbot) on May 08, 2018 at 06:46 UTC | |
by Anonymous Monk on May 14, 2018 at 06:26 UTC |