If this returns true

``````local one = 10
local two = 20

print(one and two)
``````

Then this returns false

``````local one = 10
local two = 0

print(one and two)
``````

But then does this returns true as well?

``````local one = 10
local two = 0

print(one and two or 50)
``````
1 Like

First I’ll talk a little bit about booleans.
This is a type that contains only two values, true and false. In most programming languages, false corresponds to nil(null) or 0, and true corresponds to something else. That’s why your statement returns like that.

@bjdanh266 so can you answer this?

It will return 50 not true or false

Because lua treats it as

``````((one and two) or 50)
``````

Which is equal to

``````((true and false) or true)
``````

Which is equal to

``````(false or true)
``````

Which is true

In general try to use parenthesis so the conditions are clear for you and also for the lua interpreter.

2 Likes

I think you’re wrong here. This involves logical operations not interfere.

Thank you, wanna know a fun fact?

I pretend to not know this and just give a test to see if scripters here knows a basic understanding of scripting. One point for you buddy!

2 Likes

Haha. One day you will make a good interviewer at a tech company!

1 Like