Remove matched items from array

Posted by druva | Uncategorized | Thursday 20 November 2008 2:52 pm

Remove matched items from array
This is the sample script to show how to use the class

import druva.ArrayUtils;

trace(ArrayUtils.removeMatch(new Array(2,6,8,9,2,3,5,9), 2));

Actual Class

package druva{
	import flash.display.Sprite;

	public class ArrayUtils extends Sprite {
		public function ArrayUtils() {
		}

		//@ removes matched items from the array
		public static function removeMatch(array,symbol) {
			for (var i=0; i<array.length; ++i) {
				if (array[i]==symbol) {
					array.splice(i,1);
					removeMatch(array,symbol);
					break;
				}
			}
			return array;
		}

	}
}