This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
syfygirl's profile picture

how to check if a string is blank

Started by syfygirl, 30 April 2014 - 10:05 PM
syfygirl #1
Posted 01 May 2014 - 12:05 AM
hi there i have already done some deep digging for this question but can't find the answer. if you wanted to check if a string is blank, how would you do that?

something like this ?


if mystring == nil then
  print("True!")
end
Agoldfish #2
Posted 01 May 2014 - 12:08 AM
Well, I don't knwo exactly how, but I know your method won't work. Assuming mystring exists, it will always be not nil. Well, except if mysting = nil is in there.
CometWolf #3
Posted 01 May 2014 - 12:13 AM
Like gold says, "" and nil is not the same. However, to determine if a string is emtpy, you can simply check it's length.

if #myString == 0 then
syfygirl #4
Posted 01 May 2014 - 12:14 AM
oh… sorry now i feel like this was a dumb question, thanks.