Subject: | Prefetch in constructor is unexpected behavior |
As I can see, Iterator prefeteches next value in the constructor.
This is not desirable, since you get some very unexpected results:
use Test::More tests => 1;
use Iterator;
my $value = 0;
my $iterator = new Iterator(sub { return ++$value });
is($value, 0, "Haven't called the iterator yet.");