Testing by Assertions
Nil Check
Check that a required value is present.
Nil Check
nil_check.lua
local raw =
local passed = raw ~= nil and raw ~= ""
local status = "fail"
if passed then
status = "pass"
end
print("raw=" .. tostring(raw))
print("status=" .. status)
local raw =
local passed = raw ~= nil and raw ~= ""
local status = "fail"
if passed then
status = "pass"
end
print("raw=" .. tostring(raw))
print("status=" .. status)
local raw =
local passed = raw ~= nil and raw ~= ""
local status = "fail"
if passed then
status = "pass"
end
print("raw=" .. tostring(raw))
print("status=" .. status)
required value
Checking both `nil` and an empty string catches two common missing-value cases.