Exception handling vs. hasNext()

2007-11-16 Thread Garrett Smith
Hi Erik, Can you explain a little better by showing a code example? Thanks. On Nov 16, 2007 5:44 PM, Erik Arvidsson <[EMAIL PROTECTED]> wrote: > One benefit of StopIteration is that code inside map/some/every etc > can just throw a StopIteration to stop the iteration. The same thing > is harde

Re: Exception handling vs. hasNext()

2007-11-16 Thread Erik Arvidsson
One benefit of StopIteration is that code inside map/some/every etc can just throw a StopIteration to stop the iteration. The same thing is harder to keep clean with a hasNext/next pattern. On Nov 16, 2007 5:30 PM, Garrett Smith <[EMAIL PROTECTED]> wrote: > Which is better? > > var nodes : int; >

Exception handling vs. hasNext()

2007-11-16 Thread Garrett Smith
Which is better? var nodes : int; var widgetMap = Widget.instances; // a map. var it:Iterator = widgetMap.getKeys(); -- this: -- try { widgetMap.get(it.next()).hide(); } catch(Exception e) { if(e instanceof StopIteration) { } } -- or this: -- while(it.hasNext()) { widgetMap.get(it.