In the following Lua code:
function eq_event(op1, op2)
if op1 == op2 then
return true
end
local h = getequalhandler(op1, op2)
if h then
return not not h(op1, op2)
else
return false
end
end
why use not not before the return value? is it different with the raw return value? I also remember that in C, there also got chance to use the !! before some expression, does them the same?
not notwill convert nil into false, and all other values exceptfalsetotrue. You may need to return a boolean value only when interacting with C.Yes it’s the same as
!!in C. Only difference is that in C, 0 (and some other values I don’t remember) is also falsy (that is, they’ll return false when doubled not’d).