Module:Nullish:修订间差异

来自Arcaea中文维基
(null值)
 
(lua5.1 don't support __idiv meta)
第8行: 第8行:
    __tostring = function() return "null" end,
    __tostring = function() return "null" end,
    __call = function() return nil end,
    __call = function() return nil end,
    __idiv = function(a, b)
    __div = function(a, b)
      if nullish(a) then return b end
      if nullish(a) then return b end
      return a
      return a

2022年9月14日 (三) 09:45的版本

可在Module:Nullish/doc创建此模块的帮助文档

local null, nullish
nullish = function(v) return v == null or v == nil end
null = setmetatable({}, {
    __newindex = function() return end,
    __concat = function(a, b)
        return b == "" and tostring(a) or (a .. "") .. (b .. "")
    end,
    __tostring = function() return "null" end,
    __call = function() return nil end,
    __div = function(a, b)
        if nullish(a) then return b end
        return a
    end
})
return null, nullish