Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


OpenResty 判断是否为空

OpenResty Lua 大约 269 字

注意

Lua中只有nilfalse为假,其余都为真,空字符串也为真。

判断变量为空

local str = nil
-- local str = false
if str then
    -- 不为空的情况
end

if not str then
    -- 为空的情况
end

判断字符串非空

方式一:判断长度大于0

local str = ""
if str and #str > 0 then

end

方式二:判断不等于空

local str = ""
if str and str ~= "" then

end
阅读 5653 · 发布于 2020-04-11

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批