Return to Snippet

Revision: 41685
at February 22, 2011 22:30 by feeorin


Updated Code
/**
 * 
 * @param $obj The object you want to delete elements from
 * @param parameters A comma delimeter parameters to be passed on the object for deletion, if a parameter is not found the object it will be skipped
 * @return The new object with the deleted element
 * 
 */		
public static function deleteElements ($obj:Object, ...parameters):Object {
	
	if ($obj != {} || $obj != null) {
		for (var s:String in parameters) {
			if ($obj[parameters[s]] && $obj[parameters[s]] != undefined) {
				$obj[parameters[s]] = null;
				delete $obj[parameters[s]];
			} else {
				trace ("parameter,", parameters[s], "was skipped as it couldn't be found on the object");
			}
		}
	}
	
	return $obj;
}

Revision: 41684
at February 22, 2011 10:44 by feeorin


Updated Code
/**
 * 
 * @param $obj The object you want to delete elements from
 * @param parameters A comma delimeter parameters to be passed on the object for deletion, if a parameter is not found the object it will be skipped
 * @return The new object with the deleted element
 * 
 */		
public static function deleteElements ($obj:Object, ...parameters):Object {
	
	if ($obj != {} || $obj != null) {
		for (var s:String in parameters) {
			if ($obj[parameters[s]] && $obj[parameters[s]] != undefined) {
				$obj[parameters[s]] = null;
				delete $obj[parameters[s]];
			} else {
				trace ("parameter,", parameters[s], "was skipped as it couldn't be found on the object");
			}
		}
	}
	
	return $obj;
	$obj = {};
	delete $obj;
}

Revision: 41683
at February 22, 2011 10:44 by feeorin


Initial Code
/**
 * 
 * @param $obj The object you want to delete elements from
 * @param parameters A comma delimeter parameters to be passed on the object for deletion, if a parameter is not found the object it will be skipped
 * @return The new object with the deleted element
 * 
 */		
public static function deleteElements ($obj:Object, ...parameters):Object {
	
	if ($obj != {} || $obj != null) {
		for (var s:String in parameters) {
			if ($obj[parameters[s]] && $obj[parameters[s]] != undefined) {
				$obj[parameters[s]] = null;
				delete $obj[parameters[s]];
			} else {
				trace ("parameter,", parameters[s], "was skipped as it couldn't be found on the object");
			}
		}
		getAssociativeArraySize($obj);	
	}
	
	return $obj;
	$obj = {};
	delete $obj;
}

Initial URL

                                

Initial Description

                                

Initial Title
Remove elements from an associative array

Initial Tags
array

Initial Language
ActionScript 3