When getting a specific string, what’s the difference between " " and ’ '?
There is no difference, just use whichever you prefer.
There’s a difference, there are some typos you can get while using ‘’ and “”
Example:
Though, I would not be the person to tell what is precisely the difference between both
local a,b = "''", '""'
They’re less different and more reciprocal of each other.
Edit: Hi Incapaz
Difference is double quotes can’t contain double quotes without escaping, single quotes can’t use single quotes without escaping
print("What's up? \"The sky!\"")
print('What\'s up? "The sky!"')
I think this shows it quite well. I personally don’t use single quotes because I’ll have to escape apostrophes for contractions, which are extremely common (like this post uses 4 contractions already!). And in other statically typed language there is a distinction made between string
s and single char
s, the former using double quotes and the latter using single quotes.
I assumed you meant
print("Hello world!")
vs
print('Hello world!')
In this case it wouldn’t make a difference unless you have another " or ’ in the string like @sjr04 stated
In lua both represent strings.
In other languages ''
typically represents a single character whereas ""
typically represents an array of characters (a string). This changes depending on the language, however both are literals.