AS3: Removing duplicates from an array
Just for shiggles (yes, I said it.), removing duplicate items from an array in one line of ActionScript 3:
var arr:Array = ["a","b","b","c","b","d","c"];
var z:Array = arr.filter(function (a:*,b:int,c:Array):Boolean { return ((z ? z : z = new Array()).indexOf(a) >= 0 ? false : (z.push(a) >= 0)); }, this);
trace(z);

October 22nd, 2008 at 11:33 pm
Thanks for the script!
I’ve been trying all sorts of things to cut out duplicates, but I’m not a programmer so it’s been taking me forever!
Simon.