Return to Snippet

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


Updated Code
/**
 * Returns the length of an associative array or object similar function to Array.length 
 * 
 * @param $obj
 * @return int
 * 
 */
public static function __getAssociativeArraySize($obj:Object):int {
	var length:int = 0; /* the length counter to be returned */
	if ($obj != {} || $obj != null) { /* check if the object is null or has no elements and return zero as the length */
		for (var s:String in $obj) { /* iterate on each element of the object and increase the counter */
			length++;
		}
	}
	
	return length; /* return the length*/
}

Revision: 41681
at February 22, 2011 09:42 by feeorin


Initial Code
/**
 * Returns the length of an associative array or object similar function to Array.length 
 * 
 * @param $obj
 * @return int
 * 
 */
public static function __getAssociativeArraySize($obj:Object):int {
	var length:int = 0; /* the length counter to be returned */
	if ($obj != {} || $obj != null) { /* check if the object is null or has no elements and return zero as the length */
		for (var s:String in $obj) { /* iterate on each element of the object and increase the counter */
			length++;
		}
	}
	
	return length; /* return the length*/
	length = null;
}

Initial URL

                                

Initial Description

                                

Initial Title
Get the length of an associative array

Initial Tags
array

Initial Language
ActionScript 3