lua 条件判断 nil

创建日期: 2024-05-23 17:11 | 作者: 风波 | 浏览次数: 16 | 分类: openresty

来源:https://stackoverflow.com/questions/19664666/check-if-a-string-isnt-nil-or-empty-in-lua

判断字符串是否为空

local function isempty(s)
  return s == nil or s == ''
end

if isempty(foo) then
  foo = "default value"
end
16 浏览
10 爬虫
0 评论