[Dojo-interest] [Head's Up] Collections are going to have

Cameron Braid cameron at braid.com.au
Fri Apr 14 08:09:43 MDT 2006


I still much prefer the java syntax ;

while (e.hasNext() {
    var item = e.next();
}

I just think that current() makes it sound like you can call it multiple
times to get the current record.

I don't think iterators are meant to have a current record.. they are
there to be a source of new records, which is why hasNext/next are the
most suitable method names.  

I don't like this current() atEnd() and .element syntax.

I'd implement is such that next() returns the next element, if one
exists, otherwise it should throw an exception, not return null.

Cameron.

On Thu, 2006-04-13 at 12:21 -0500, Tom Trenka wrote:

> If you intentionally populate a collection with null values (which I'm not sure why you'd do but is certainly possible), you'll want to use the atEnd() method for the test as opposed to current:
> 
> while(!e.atEnd()){
>    var item=e.current();  // get and advance
> }
> 
> Hopefully it means you can have your cake and eat it, too.
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=25809&messageID=50945#50945
> 
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest


________________________________________________________________________
Cameron Braid
PGP Public Key http://braid.com.au/cameron.pgp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mastodon.dojotoolkit.org/pipermail/dojo-interest/attachments/20060414/803ebd2e/attachment.html


More information about the Dojo-interest mailing list