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

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

SEE ALSO
foreach
objc:arrayFromList
objc:listFromArray

KEYWORDS
foreach, iteration, list, looping, container object

Index