Well now I just feel dumb.  That's much better than my while loop, and
simple enough I should have thought of it (I've even done something
like that before).  Doh!

 -Andy

On 12/21/06, Jim Kremens <[EMAIL PROTECTED]> wrote:
"for (var i:Number = array.length - 1; i >= 0; --i) {
   if (!test(array[i])) {
       array.splice(i, 1);
   }
}"

This is correct and well tested...  Look in any of the AS code
libraries and you'll find many variations on this theme.

Jim Kremens

On 12/21/06, T. Michael Keesey <[EMAIL PROTECTED]> wrote:
> Well, easy enough, then:
>
> for (var i:Number = array.length - 1; i >= 0; --i) {
>    if (!test(array[i])) {
>        array.splice(i, 1);
>    }
> }
>
> On 12/21/06, Andy Herrman <[EMAIL PROTECTED]> wrote:
> > Even if it iterates backwards, I don't think I'd trust it.  I don't
> > like the idea of relying on an implementation detail of the for-in
> > loop in order to make my stuff work.  In general I see  for-in loops
> > (any language) as loops that use an arbitrary ordering, and as such
> > you shouldn't rely on any particular ordering for your code to work.
> > I tend to think it's safer to approach things this way, as it protects
> > you from any changes in the implementation details.  Just the fact
> > that you're "Not sure about AS3" is reason enough I think.
> >
> > But maybe I'm just paranoid. :)
> >
> >    -Andy
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>


--
Jim Kremens
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to