RosettaCodeData/Task/Multiple-distinct-objects/Tcl/multiple-distinct-objects.tcl
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

13 lines
302 B
Tcl

package require TclOO
# The class that we want to make unique instances of
set theClass Foo
# Wrong version; only a single object created
set theList [lrepeat $n [$theClass new]]
# Right version; objects distinct
set theList {}
for {set i 0} {$i<$n} {incr i} {
lappend theList [$theClass new]
}