What's the difference between creating a string with quotation marks and brackets?

4

I always created the strings with the quotation marks, like this:

local minhaString = "Eu sou uma string"

I downloaded a source to give a studied language and I came across the following way to create a string :

local query = [[
SELECT *
FROM 'pointshop_data'
WHERE uniqueid = '%s'
]]

What is the advantage / difference in using [[ / ]] ? How do I pass the %s ? Parameter

    
asked by anonymous 20.12.2017 / 01:35

2 answers

4

The bracketed form is brute, it essentially does not work with special characters and considers "everything" as text, including when it skips the line. It's like using the @ of C # .

To use arguments to be inserted into the text you must use the string.format() function.

    
20.12.2017 / 01:45
2

The main difference is that strings created with quotation marks accept escape sequences such as \n and \t . Strings created with brackets do not interpret any escape sequences. See the manual .

% w / w in your example indicates that the string is likely to be used as a format in %s . Other than that, there is no special meaning.

    
20.12.2017 / 01:48