develooper Front page | perl.module-authors | Postings from November 2003

Re: Class::FakeAttributes -- Opinions Wanted

Thread Previous | Thread Next
From:
darren chamberlain
Date:
November 3, 2003 09:24
Subject:
Re: Class::FakeAttributes -- Opinions Wanted
Message ID:
d1223ce8b4e8be3a68a693c2548b0cf5e7724e1e@tumbleweed.boston.com
* A. Pagaltzis <pagaltzis at gmx.de> [2003-11-03 17:38]:
> * Orton, Yves <yves.orton@de.mci.com> [2003-11-03 17:27]:
> > > If the 'foo' attribute hasn't been set to anything, then you
> > > want an empty list to iterate over.  With version C, that's
> > > what you get.  
> > 
> > No. If $self->{foo} is undef you get an error with version C.
> 
> You're forgetting autovivification. If $self->{foo} is undef it
> is coerced into a appropriate reftype.

  $ perl -Mstrict -wle 'my $f = { }; my @a = @{ $f->{foo} }'
  Can't use an undefined value as an ARRAY reference at -e line 1.

(darren)

-- 
How you look depends on where you go.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About