Skip Menu |

This queue is for tickets about the MooseX-Iterator CPAN distribution.

Report information
The Basics
Id: 54811
Status: open
Priority: 0/
Queue: MooseX-Iterator

People
Owner: Nobody in particular
Requestors: lorenz.knies [...] xing.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: I would have expected the peek method to work differently.
Hi Robert, For me the following command-line prints 5,4 while i would have expected it to print 4,4: perl -MMooseX::Iterator -e 'my $iter = MooseX::Iterator::Array->new(collection => [4,5,6,7]); print $iter->peek(), ",", $iter->next(), "\n"'; The documentation says: The next method provides the next item in the colletion. The peek method returns the next item without moving the state of the iterator forward. So they both return the value of the next item, so called in this order (first peek, then next), shouldn't they return the same value? Regards, Lorenz
Am Fr 19. Feb 2010, 17:34:48, lknies schrieb: Show quoted text
> Hi Robert, > > For me the following command-line prints 5,4 while i would have > expected it to print 4,4: > perl -MMooseX::Iterator -e 'my $iter = MooseX::Iterator::Array-
> >new(collection =>
> [4,5,6,7]); print $iter->peek(), ",", $iter->next(), "\n"'; > > The documentation says: > The next method provides the next item in the colletion. > The peek method returns the next item without moving the state of the > iterator forward. > > So they both return the value of the next item, so called in this > order (first peek, then next), > shouldn't they return the same value? > > Regards, > Lorenz > >
This behavior makes the peek method useless so I doubt that anyone is using it. Which means that you could fix that behavior to be compliant with common sense.