Re: CDBI::Iterator->first moves it's index pointer
[prev]
[thread]
[next]
[Date index for 2004/11/10]
On Wed, Nov 10, 2004 at 06:23:15PM +0100, Rhesa Rozendaal wrote:
> It turns out that "first" does this:
> my $self = shift;
> $self->reset;
> return $self->next;
> In other words, it moves the iterator to the next element, returning the
> first.
Not quite. It moves the iterator to before the start of the list, and
then returns the 'next' one (which is, by definition, the first one.
> I expected it to return the first element, and not move its index
> pointer.
That would be weird.
Consider:
my $it = run_some_search();
print $it->first;
print $it->next;
print $it->first;
print $it->next;
Would you really expect this to print 1, 2, 1, 3? I'd say most people
would expect 1, 2, 1, 2.
I'm open to opinions here.
Tony
|
|
Re: CDBI::Iterator->first moves it's index pointer
Tony Bowden 19:31 on 10 Nov 2004
|