Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Method Chaining and Accessors

by Moron (Curate)
on Apr 05, 2007 at 12:49 UTC ( [id://608470]=note: print w/replies, xml ) Need Help??


in reply to Re: Method Chaining and Accessors
in thread Method Chaining and Accessors

Almost, but because the object arrives in $_[0] either way, you need to shift it out before testing @_, e.g. ...
sub foo { my $self = shift; @_ or return $self -> {foo}; $self ->{foo} = shift; $self; }

-M

Free your mind

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://608470]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found