Function Lua异或函数代码
这段代码在Lua中作为xor函数工作吗Function Lua异或函数代码,function,lua,xor,Function,Lua,Xor,这段代码在Lua中作为xor函数工作吗 function xor (a,b) if a ~= b then return true else return false end end i = false j = false if xor(not i, not j) then print("one exclusive") else print("both or none") end 是的,你的代码有效 如果a和b包含布尔值,那么a异或b与not(a==b)相同,这当然与 a~=
function xor (a,b)
if a ~= b then return true else return false end
end
i = false
j = false
if xor(not i, not j) then
print("one exclusive")
else
print("both or none")
end
是的,你的代码有效
如果a
和b
包含布尔值,那么a异或b
与not(a==b)
相同,这当然与
a~=b
我不知道怎么做?为什么需要xor?函数xor(a,b)返回not a~=not b end