public
Created

  • Download Gist
typeParams.as
ActionScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
var ints = [1, 2, 3]
var strings = ["a", "bb", "ccc"];
 
var biggerThan1 = function(x:Int) {
return x > 1;
}
 
var longerThan1 = function(x:String) {
return x.length > 1;
}
 
function array_delete_if<T>( array: Array<T>, processor: T-> Bool ):Array<T>
{
for ( item in array )
if ( processor(item) )
array.remove( item );
return array;
}
 
array_delete_if(ints, biggerThan1); // [ 1 ]
array_delete_if(strings, longerThan1); // [ "a" ]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.