Joy Online Manual

NAME
objc:foreach - Iterate over a container object

SYNOPSIS

objc:foreach variable object script

DESCRIPTION
Iterates variable over object executing the Tcl code script. The container object object must implement the objectEnumerator message such as NSArray, NSDictionary and NSSet do.
The break and continue statements may be invoked inside body, with the same effect as in the for and foreach command.  objc:foreach returns an empty string.

EXAMPLE

joy> set one [[NSNumber numberWithInt: 1] retain]
NSshortNumber@0x155b80
joy> set two [[NSNumber numberWithInt: 2] retain]
NSshortNumber@0xd4ef4
joy> set three [[NSNumber numberWithInt: 3] retain]
NSshortNumber@0x162c68
joy> set a [[objc:arrayFromList "$one $two $three"] retain]
NSConcreteMutableArray@0x27e278
joy> set sum 0
0
joy> objc:foreach i $a {
incr sum [$i intValue]
}
joy> set sum
6

SEE ALSO
foreach
objc:arrayFromList
objc:listFromArray

KEYWORDS
foreach, iteration, list, looping, container object

Index