Closures/Value capture: Difference between revisions

Content deleted Content added
Adding Lua Solution
m Correction to Lua to bring in line with task
Line 590:
funcs={}
for i=1,10 do
table.insert(funcs, function() print(i,return i*i) end)
end
funcs[2]()
Line 596:
</lang>
Output:
<pre>2 4
9
3 9
</pre>