in reply to Re: OO - inside-out or by means of a anonymous sub?
in thread OO - inside-out or by means of a anonymous sub?
$self->{attribute} becomes $self->[ATTRIBUTE] (where ATTRIBUTE is an integer constant). Those constants should not be visible outside of the package published or exported, because they're an implementation detail.
Admittedly, the initialization code becomes a bit less beautiful, but it's still perfectly clear:
Variations on this that avoid declaring an array would probably be uglier.sub new { my ($class) = @_; my @obj; @obj[ACCOUNT, NAME, BALANCE] = (undef, undef, 0); return bless( \@obj, $class); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: OO - inside-out or by means of a anonymous sub?
by ikegami (Patriarch) on Jan 12, 2006 at 16:30 UTC |