在Lua中,我写了以下内容:
for s in string.gmatch(path, "([^'\']+)") do
if not s then -- if s ~= nil then
table.insert(path_tb, s)
print(s)
end
end
如果我用if s ~= nil then
替换if not s then
,我会得到不同的结果。这背后的原因是什么?
当s
为零或s
为假时,not s
为真。