Fwd: [dojo-contributors] [feedback wanted] Preferred Iteration forms

Alex Russell alex at dojotoolkit.org
Wed Apr 12 14:41:44 EDT 2006


On Wednesday 12 April 2006 11:39 am, James Burke wrote:
> On 4/12/06, Tom Trenka <ttrenka at gmail.com> wrote:
> [snip]
>
> > var it=col.getIterator();
> >
> > while(!it.atEnd()){
> >     var item=it.current();
> >     // do stuff
> >  }
> >
> > The idea here is that current() not only returns the current item,
> > but also advances the internal cursor to the next item in the
> > collection.  atEnd() should be obvious. I will also provide an
> > "item" property, which will be the current item in the collection.
> > Hopefully this is the best comprimise I can think of.  It should
> > also be able to support a for form...
> >
> > for(it.current();!it.atEnd(); it.current()){
> >    // do stuff.
> > }
>
> if current() does a next operation underneath, I would then prefer
> calling the method next(). To me current implies I can call it many
> times and get the same value (no cursor movement). But that may be my
> java experience coloring my perception. Please disregard if this
> falls into the holy war section.

+1 to James' suggestion.

-- 
Alex Russell
alex at jot.com
alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20060412/b5cb9c55/attachment.sig 


More information about the dojo-contributors mailing list