Log In  


This code does not work (unexpected symbol near 'then'):
if (x == "\\") then print(x) end

But this works OK:
bs = "\\" if (x == bs) then print(x) end

1


Tried fiddling a bit to see if I could repro on my machine...

This first one executes correctly (prints "char 7 is \"), but the syntax-highlighter thinks that the "then" keyword and the print statement's closing parenthesis are contained inside of the strings on their lines:

if char=="\" then

This one fails to execute:

if (char=="\") then

It seems like under "certain conditions" in the pipeline, the second backslash is still getting viewed as if it was an escape-character, and that's somehow "half-escaping" the ending quote mark. Very strange that the highlighter and the actual code parser are getting different results like that!

Snippet if you wanna try other variations:

x="hello \\"

for i=1,#x do
	char=sub(x,i,i)
	if char=="\\" then
		print("char "..i.." is \\")
	end
end


[Please log in to post a comment]