Re: table reset
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: table reset
- From: Kaos <kaos@...>
- Date: 2004年7月13日 08:55:29 +0200
Jamie Webb wrote:
On Mon, Jul 12, 2004 at 07:48:00AM +0200, Kaos wrote:
Jamie Webb wrote:
On Sat, Jul 10, 2004 at 06:44:21PM +0200, Markus Huber wrote:
-- Wich version is better and why? Any suggestions are welcome.
[snip] In fact, as written, it won't work at all. The declaration of
Lines needs to be moved outside the loop.
I would agree, if it wasn't for the ... or {} part, which I actually
think would make it work as intended (not tested).
Nope. That line will just always be equivalent to 'local Lines = {}',
i.e. all lines will be discarded immediately after they are read. The
problem is that because Lines is declared inside the loop, its scope
does not extend across iterations.
-- Jamie Webb
Hmmm... got to look closer at what's happening here (remeber some pseudo
code about loops from the manual)...
but I've verified the fact:
> do
>> local i = 0
>> while i < 5 do
>> local foo = foo or {}
>> foo[i] = i ^ 2
>> i = i + 1
>> print( "foo ", foo, "\n" )
>> table.foreach(foo, print)
>> end
>> end
foo table: 0x808e140
0 0
foo table: 0x808fd58
1 1
foo table: 0x8090688
2 4
foo table: 0x808eca8
3 9
foo table: 0x808e910
4 16
>