Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by enoch (Chaplain)
on Nov 25, 2003 at 18:45 UTC ( #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
Node Status?
node history
Node Type: note [id://310013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2021-01-23 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?