I have seen code in lua like this
if (a==b or false) then
what is the purpose of the “or false”?
This is the original code:
Function = function(self, aura, auraID)
-- Store the version.
-- aura.Version = 50000;
-- Fix texmode/glow.
aura.texmode = (aura.texmode == 1 or aura.texmode == true or false);
-- Texture source.
if(aura.owntex or aura.SourceType == PowaAuras.SourceTypes.Icon) then
aura.SourceType = PowaAuras.SourceTypes.Icon;
elseif(aura.wowtex or aura.SourceType == PowaAuras.SourceTypes.WoW) then
aura.SourceType = PowaAuras.SourceTypes.WoW;
elseif(aura.customtex or aura.SourceType == PowaAuras.SourceTypes.Custom) then
aura.SourceType = PowaAuras.SourceTypes.Custom;
elseif(aura.textaura or aura.SourceType == PowaAuras.SourceTypes.Text) then
aura.SourceType = PowaAuras.SourceTypes.Text;
else
aura.SourceType = PowaAuras.SourceTypes.Default;
end
end
And here is another example
-- Iterate over element children.
visible, hidden = self:UpdateScrollList(key, level+1, visible, hidden,
(parentShowing == true and item:GetExpanded() or false));
This looks like a behavior that comes from the syntax:
to initialize
ato the value ofborfalseifbisn’t defined.Within the
ifstatement as you wrote it, I don’t see any purpose since the==is evaluated before theor. If they used parenthesis to change the order of operations, then it could be used to validate thatbhas been defined, e.g.: