Which is better?

var nodes : int;
var widgetMap = Widget.instances; // a map.
var it:Iterator<string> = widgetMap.getKeys();

 -- this: --

try {
  widgetMap.get(it.next()).hide();
}
catch(Exception e) {
  if(e instanceof StopIteration) {

  }
}


 -- or this: --

while(it.hasNext()) {
  widgetMap.get(it.next()).hide();;
}

It might be the case that there might be some error
I want to catch other than StopIteration. In that case, to be
backwards-compatible and work across implementations, the developer
must use conditional
checks inside 1 catch block.

A hasNext() would not prevent the developer from writing such code.
Omitting hasNext() forces developers to use exception handling for
non-exceptional condition.

How does using try/catch for normal termination of the loop look?

It looks like all exceptions are unchecked in ES4. correct?  (I cannot
verify this to be true because
I am unable to access the spec namespace on ecmascript.org.)
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to