[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Closures
- From: Jack Christensen <jack@...>
- Date: Wed, 12 May 2004 18:55:14 -0500
I'm getting some results I was not expecting with this code.
functionList = {}
for i=1, 10 do
functionList[ i ] = function()
print( i )
end
end
for i=1, 10 do
functionList[ i ]()
end
I get ten 10's printed out. As I understand closures I would have
expected 1 to 10. Could someone enlighten me as to what is wrong?
Thanks.
Jack