-
Posted by Fogger on Wed, 28 Jan 2009 04:59:26
The counter is supposed to be private, but it can be accessed using print(counter)
The do/end block doesnt limit scope at all. what's up with that?
eg:
do
private = "oh noes"
end
print(private)
> oh noesI even tried
local counter = 0
, but the result was the same. Interpreter error? -
Posted by Fogger on Wed, 28 Jan 2009 04:59:26
The counter is supposed to be private, but it can be accessed using print(counter)
The do/end block doesnt limit scope at all. what's up with that?
eg:
do
private = "oh noes"
end
print(private)
> oh noesI even tried
local counter = 0
, but the result was the same. Interpreter error? -
Posted by Fogger on Wed, 28 Jan 2009 06:56:24
well, it seems the example does indeed return
nil
when thelocal
prefix is used, thoughlocal
isnt used in the book. -
Posted by jnwhiteh on Wed, 28 Jan 2009 08:24:01
If local isn't used, then it's an error in the printing. My apologies.
-
Posted by Fogger on Wed, 28 Jan 2009 09:24:53
I just thought I was going crazy, could swear I tested it with local the first time.
maybe I didnt save the script after adding the local prefix or forgot to reload it in the interpreter. /sigh
thank you for your response and a great book!