“模块:StringUtils”的版本间的差异
跳到导航
跳到搜索
(建立内容为“local p = {} function p.split_or_empty(value, sep) if value and #value > 0 then return mw.text.split(value, sep) else return {} end e…”的新页面) |
|||
| 第6行: | 第6行: | ||
else | else | ||
return {} | return {} | ||
| + | end | ||
| + | end | ||
| + | |||
| + | function p.assert_not_empty(s) | ||
| + | if s and #s == 0 then | ||
| + | return nil | ||
| + | else | ||
| + | return s | ||
end | end | ||
end | end | ||
return p | return p | ||
2020年12月31日 (四) 23:20的版本
此模块的文档可以在模块:StringUtils/doc创建
local p = {}
function p.split_or_empty(value, sep)
if value and #value > 0 then
return mw.text.split(value, sep)
else
return {}
end
end
function p.assert_not_empty(s)
if s and #s == 0 then
return nil
else
return s
end
end
return p