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

Sandro Magi smagi at naasking.homeip.net
Tue Apr 4 09:13:46 EDT 2006

Tom Trenka wrote:
> The ideal would be to not use it at all, which is basically what I've
> arguing with you guys about.  I've no problem creating the dependency
> with the search trees and graph; both of the those are much more complex
> than the other collections.
> Jeez, all I wanted to know was which style of imperative iterator we
> preferred.

Minimal seems best:

var it = obj.getIterator();
while(it.next()) {
  var cur = it.current; //or it.value, or ...

Smallest, simplest interface (1 method + 1 property), less likely to get
the iteration pattern wrong. I recommend the same interface be used for
the Dictionary too; just return A DictionaryEntry or a 2-element array
so the iteration looks the same.


More information about the dojo-contributors mailing list