With my code, I at least get an error. So it looks like an improvement but not in the way I thought.my $cd = Music->new(name => 'Four Seasons', arist => 'Vivaldi', rating + => 7,);
Looking again at his code, I see you are correct: if the argument given doesn't exist as an attribute, it is getting ignored rather than autovivified as I mistakenly assumed. What confused me I didn't read close enough is Conway's second paragraph of page 119:
I'm beginning to think he is talking about autovivification that occurs from code located within the class like what happens on page 129 with his Transceiver class and not autovivication during object construction. Am I right on this? Thanks for the help.If you have a reference to a hash-based object, say, $objref, and you' +re using an attribute such as $objref->{_weirdness_factor}, then chan +ces are that somewhere in the heat of coding, you'll accidentally wri +te something like $objref->{_wierdness_factor}++.
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
In reply to Re: Re: Preventing autovivification of object attributes
by nysus
in thread Preventing autovivification of object attributes
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |