lua-users home
lua-l archive

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


Hello,

 

Since it’s my first post here, I first just wanted to say hello and thanks for what you have done with Lua!

 

Here is a small code where I’ve got an unexpected behavior (tried with Lua 5.1.4):

 

local _OneOrTwo_ = (1 or 2)

local a = (OneOrTwo) and true or false

local b = (1 or 2) and true or false

local True = true

local c = (1 or 2) and True or false

 

print(a)

print(b)

print(c)

 

The result is :

 

true

1

true

 

I was expecting to get the following result:

 

true

true

true

 

Is this a bug, or can someone can explain me why we have 1 instead of true?

 

Thanks!

 

 

-----

Thierry Van Elsuwé

AI/Gameplay Programmer - Undisclosed Project

Ubisoft Montréal