Minecraft Wiki
Advertisement

p.merge simplification

if not norm or norm and v ~= '' then can be simplified to if not norm or v ~= '' then.

for _, x in ipairs{true, false} do
  for _, y in ipairs{42, ''} do
    local cond = not x or x and y ~= ''
    mw.log(string.format('* %q, %q, %q', tostring(x), tostring(y), tostring(cond)))
  end
end
* "true", "42", "true"
* "true", "", "false"
* "false", "42", "true"
* "false", "", "true"

for _, x in ipairs{true, false} do
  for _, y in ipairs{42, ''} do
    local cond = not x or y ~= ''
    mw.log(string.format('* %q, %q, %q', tostring(x), tostring(y), tostring(cond)))
  end
end
* "true", "42", "true"
* "true", "", "false"
* "false", "42", "true"
* "false", "", "true"

--BryghtShadow (talk) 18:16, 4 April 2020 (UTC) Edit: Forgot to nowiki the double apostrophe, woops. --BryghtShadow (talk) 18:18, 4 April 2020 (UTC)

Advertisement