Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Empty-string/Lua/empty-string.lua
Normal file
25
Task/Empty-string/Lua/empty-string.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- create an empty string 3 different ways
|
||||
str = ""
|
||||
str = ''
|
||||
str = [[]]
|
||||
|
||||
-- test for empty string
|
||||
if str == "" then
|
||||
print "The string is empty"
|
||||
end
|
||||
|
||||
-- test for nonempty string
|
||||
if str ~= "" then
|
||||
print "The string is not empty"
|
||||
end
|
||||
|
||||
-- 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue