StructEach

call the given UDF/Closure with every entry (key/value) in the struct.

Returns: void

Usage

StructEach( struct, closure [, parallel [, maxThreads ] ] )

Arguments

Argument Description Default
struct
(struct, required)

struct to take values from

closure
(function, required)

UDF/Closure that call with the entries from struct

parallel
(boolean, optional)

execute closures parallel

maxThreads
(number, optional)

maximum number of threads executed, ignored when argument "parallel" is set to false

20

Examples

Member Function

animals = {
	cow: "moo",
	pig: "oink",
	cat: "meow"
};

animals.each(function(key) {
	// Show key 'arguments.key'
	Dump(
		label: "Key",
		var: arguments.key
	);

	// Show key's value 'animals[arguments.key]'
	Dump(
		label: arguments.key & "'s value",
		var: animals[arguments.key]
	);
});

Non-Member Function

animals = {
	cow: "moo",
	pig: "oink",
	cat: "meow"
};

StructEach(animals, function(key) {
	// Show key 'arguments.key'
	Dump(
		label: "Key",
		var: arguments.key
	);

	// Show key's value 'animals[arguments.key]'
	Dump(
		label: arguments.key & "'s value",
		var: animals[arguments.key]
	);
});

See also