Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Why get() and set() accessor methods are evil

by enoch (Chaplain)
on Nov 25, 2003 at 18:45 UTC ( [id://310013]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package OOtest;
    sub new {
    ...
       my $self = shift;
       return $self->{list};
    }
    
  2. or download this
    my $obj = OOtest->new();
    # NOT foreach my $tmp ( @{ $obj->list() } 
    foreach my $tmp ( @{ $obj->get_array() } ) {
       # process list
    }
    
  3. or download this
    package OOtest;
    sub new {
    ...
       my $self = shift;
       return values %{$self->{list}}; # anything asking for an array gets
    + it
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-29 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found