lua-users home
lua-l archive

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


On Thu, Feb 7, 2013 at 8:54 PM, Desislav Velchev
<desislav.velchev@gmail.com> wrote:
> I've been trying out the logical expressions (from a tutorial) and I came
> accross a strange bug. Here's the code I wrote and it's output:
> Code:
> print(3 == 2);
> print(not false);
> print(not 3 == 2);
>
> Output:
> false
> true
> false
>
> So if 3==2 is an obviously false statement and the "not" keyword inverts
> false to true, how can the "not" of a false statement also return false?
>
> I am using Sublime Text 2 and I downloaded the latest version of LUA, so I'd
> really like to know if this is a bug from the language, from ST2 or have I
> made a mistake somewhere.

Order of operations.

> print(not 3) --3 is not false or nil, so evaluates to true
false
> print(not (3 == 2)) --what you intended
true
> print((not 3) == 2) --what you got
false

-- 
Sent from my Game Boy.