Multiple distinct objects: Difference between revisions

Content added Content deleted
(→‎Tcl: Added implementation)
Line 266:
"show it"
c do: [ :e | e printNl ].</lang>
=={{header|Tcl}}==
<lang Tcl># Wrong version; only a single object created
set theList [lrepeat $n [Foo new]]
 
# Right version; objects distinct
set theList {}
for {set i 0} {$i<$n} {incr i} {
lappend theList [Foo new]
}</lang>