Le 14 mars 2015 12:16, "Sebastian Sastre" <sebastian@flowingconcept.com> a ��crit :
>
> In such cases I might use a stream and monitor the `stream position` and iterate with
>
> [ stream atEnd ] whileFalse: [
> �� item := stream next.
> �� stream position even ifTrue: [ self highlight: item ].
> �� .... ]
>

Exactly!

Streams and collections are perfect for that.

And they can even do:

ReadStream class >> on:from:to:

or upTo: etc.

Phil

> from mobile
>
> > On 10/03/2015, at 09:11, Sanjay Minni <sm@planage.com> wrote:
> >
> > Hi
> >
> > when iterating over a sequenced collection (array / ordered collection) how
> > can I determine the current objects index value (without explicitly storing
> > a counter or looking to match each time)
> >
> > Typically I need it:
> > 1. to display a serial number when printing a report.
> > 2. to determine if I am on the last element.
> > 3. To highlight every n-th element.
> >
> > regards
> > Sanjay
> >
> >
> >
> >
> > -----
> > ---
> > Regards, Sanjay
> > --
> > View this message in context: http://forum.world.st/when-iterating-over-a-collection-how-to-determine-the-current-objects-index-tp4810920.html
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
>
>