I have tried using [[ and ]] but those attempts completely failed. Could someone help me?
These are my attempts:
code = [[print("testing")]]
code = [[print("testing")]]
code()
I have tried using [[ and ]] but those attempts completely failed. Could someone help me?
These are my attempts:
code = [[print("testing")]]
code = [[print("testing")]]
code()
[[ and ]] are used similarly to " and " but have the advantage of being able to be on multiple lines. So what your code is doing is just setting the variable code as a string. If you want to print something using [[ and ]] you should of done
print([[testing]])
There are a few ways to write a String in Lua. The following are all identical strings:
print([[testing]])
print("testing")
print('testing')
Using double brackets is useful for two main reasons. The first, it allows for multi-line strings.
print([[testing
We skipped a line!]])
Another useful thing, is if your string has the other symbols for writing a string included:
--Assume our string is: How's it going, "bro?"
print("How's it going, "bro?"") --the " inside the string makes the strings; "How's it going, " and "" but Lua doesn't know with to do with them because there is no concatenation.
print('How's it going, "bro?"') --the ' inside the string makes the the string end earlier than it should
print([[How's it going, "bro?"]]) --Works great
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Thanks!
No problem C:
your* c:
c: