简体   繁体   中英

LUA - Simple code supposed to work isn't working (Roblox)

Simple piece of code, supposed to work isn't working... I really can't understand this. This is code:

local asd = 1
if not asd == nil then
print("works")
end

That's it, is not printing "works", ;-; sorry if I'm missing something.

Operator precedence fooled you:

if not asd == nil then

is equivalent to

if (not asd) == nil then

Try

if not (asd == nil) then

Sorry, answer was doing

local asd = 1
if asd ~= nil then
print("works")
end

I didn't even knew that ~= is a thing wow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM