Re: [CDBI] cdbi objects evaluating as false

"Aaron Trevena" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
On 25/11/06, Matt S Trout <dbix-class-uY5y5/[email protected]> wrote:
> What's wrong with
>
> while (defined (my $object = $iterator->next)) {
>    ...
> }
>
> ?
>
> In general you want to do that anyway with stuff that might stringify
> just in case the stringification turns out to be an expensive
> operation or whatever ...

Nothing is wrong with it, it's a better alternative than what else I
was doing, but it's still not the plain loop you would expect, on the
plus side not only does it save any potentially expensive
stringification (fortunately we don't have that in this case), but it
also warns anybody maintaining that the object could be defined but
false in case they were hoping to do something somewhere else, which
reminds me I need to put a caveat along these lines in the pod.

So I think I'll go with that - now I just need to be able to do the
same in TT, where I am using the same iterator and horrid variation on
the while loop. bah.

Cheers,

A.

-- 
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Hosting
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.