LUA - 简单的代码应该能工作却没法工作(Roblox)

简单的一段代码,本应该能工作,但是它没法工作……我真的不明白为什么。 这是代码:

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

就是这样,不打印“works”,;-; 如果我漏了什么,请原谅。

点赞
用户10275408
用户10275408

抱歉,答案还在处理中。

local asd = 1
如果 asd ~= nil 这样写就行
print("有效")
结束

我甚至不知道 ~= 是个什么东西,哇!

2020-04-29 22:35:18
用户107090
用户107090

运算符优先级欺骗了你:

if not asd == nil then

等价于

if (not asd) == nil then

尝试

if not (asd == nil) then
2020-04-29 23:12:08