lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Good morning (well, it's morning here in Germany, at least)

>>  local Result = false;  -- you could also use "nil" here
>>     Result = Result or "anything else";
>>   io.stdout:write("Result = '"..tostring(Result).."'");
>
>What if you write:
>
>  local Result = false;  -- you could also use "nil" here
>   io.stdout:write("Result = '"..tostring(Result).."'");

This gives "false" or "nil" resp.

>The "or" seems to work from your post, so maybe it is not making the  
>local variable correctly.

No, it doesn't - the result of "or" should be "anything else",
since <false> or <nil> are logically "false"  and  "or" should
thus return its second argument  (it's "and", which yields its
first argument, if that is false)

The behaviour is also the same,  regardless of  whether  I use
global or local variables.

Kind regards,

Andreas Rozek         Phone:  ++49 (7031) 436 5784
Brunnenstraße 30/2    Mobile: ++49 (151) 172 879 18
D-71032 Böblingen     EMail:  Andreas.Rozek@gmx.de
Germany               URL:    http://www.Andreas-Rozek.de