in reply to Re: truth in while condition (updated)
in thread truth in while condition
The following iterator returns no "\n" but still fails to stop at "truly false" number 0.
see explanation here
use strict; use warnings; use feature 'say'; my $i = Iterator->new([1,0,2,undef,3]); while ( <$i> ) { say "<$_>"; } package Iterator; use overload '<>' => sub { shift @{$_[0]} }; sub new { my ($class,$obj) =@_; bless $obj, $class; }
-->
<1> <0> <2>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|