--,___________________________________________________________________,
--| *NOTE* - Because nil cannot be accurately represented in a string |
--| without actually typing 'nil' or '', some of the output may |
--| seem a little misleading... But the point is to understand |
--| the meaning behind the relational "negation of equality" |
--| operator, found at: http://w...content-available-to-author-only...a.org/pil/3.2.html |
--`-------------------------------------------------------------------'
--[[-------------------------------------
--Test #1: Check if NOT nil
--]]-------------------------------------
print("--[ Test #1: Check if NOT nil ]--")
local value = nil
if(value ~= nil) then
print("a.) ["..tostring(value).."] is NOT nil")
else
print("a.) ["..tostring(value).."] is nil")
end
value = ''
if(value ~= nil) then
print("b.) [\""..tostring(value).."\"] is NOT nil")
else
print("b.) [\""..tostring(value).."\"] is nil")
end
value = 'string'
if(value ~= nil) then
print("c.) [\""..tostring(value).."\"] is NOT nil")
else
print("c.) [\""..tostring(value).."\"] is nil")
end
print("\n")
--[[-------------------------------------
--Test #2: Check if NOT empty
--]]-------------------------------------
print("--[ Test #1: Check if NOT empty ]--")
value = nil
if(value ~= '') then
print("a.) ["..tostring(value).."] is NOT empty")
else
print("a.) ["..tostring(value).."] is empty")
end
value = ''
if(value ~= '') then
print("b.) [\""..tostring(value).."\"] is NOT empty")
else
print("b.) [\""..tostring(value).."\"] is empty")
end
value = 'string'
if(value ~= '') then
print("c.) [\""..tostring(value).."\"] is NOT empty")
else
print("c.) [\""..tostring(value).."\"] is empty")
end
print("\n")
--[[-------------------------------------
--Test #3: Check if NOT nil AND NOT empty
--]]-------------------------------------
print("--[ Test #1: Check if NOT nil AND NOT empty ]--")
value = nil
if(value~=nil and value~='') then
print("a.) ["..tostring(value).."] is NOT nil AND NOT empty")
else
print("a.) ["..tostring(value).."] is nil AND empty")
end
value = ''
if(value~=nil and value~='') then
print("b.) [\""..tostring(value).."\"] is NOT nil AND NOT empty")
else
print("b.) [\""..tostring(value).."\"] is nil AND empty")
end
value = 'string'
if(value~=nil and value~='') then
print("c.) [\""..tostring(value).."\"] is NOT nil AND NOT empty")
else
print("c.) [\""..tostring(value).."\"] is nil AND empty")
end
print("\n")
--[[-------------------------------------
--Test #4: Check if NOT nil OR NOT empty
--]]-------------------------------------
print("--[ Test #1: Check if NOT nil OR NOT empty ]--")
value = nil
if(value~=nil or value~='') then
print("a.) ["..tostring(value).."] is NOT nil OR NOT empty")
else
print("a.) ["..tostring(value).."] is nil OR empty")
end
value = ''
if(value~=nil or value~='') then
print("b.) [\""..tostring(value).."\"] is NOT nil OR NOT empty")
else
print("b.) [\""..tostring(value).."\"] is nil OR empty")
end
value = 'string'
if(value~=nil or value~='') then
print("c.) [\""..tostring(value).."\"] is NOT nil OR NOT empty")
else
print("c.) [\""..tostring(value).."\"] is nil OR empty")
end