Jump to content

Empty string: Difference between revisions

Line 987:
 
=={{header|Lua}}==
<lang Lua>str = "" -- create empty string
-- create an empty string 3 different ways
str = ""
str = ''
str = [[]]
 
-- test for empty string
Line 997 ⟶ 1,001:
if str ~= "" then
print "The string is not empty"
end</lang>
 
-- several different ways to check the string's length
if string.len(str) == 0 then
print "The library function says the string is empty."
end
if str:len() == 0 then
print "The method call says the string is empty."
end
if #str == 0 then
print "The unary operator says the string is empty."
end
 
</lang>
 
=={{header|M2000 Interpreter}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.