in reply to Re^2: Objects and passing/calling methods
in thread Objects and passing/calling methods
I was under the assumption that self and class are always passed inherently.
I can recommend a read of perlobj, which says (among many other useful things):
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().
And BTW, since there was mention of it further down in the thread, having to retrieve the class of one's own object with something like ref would seem like a code smell to me, most things can (and should) be solved with the appropriate OO concepts (encapsulation, inheritance, etc.). But I guess you were asking about the class out of curiosity, not because you need it?
|
|---|