Help with Strings


While defining a string, when should I use a single quote and when should I use a double quote?
I understand that the string output is same irrespective o the type of the quotes used. But wondering if there are any best practices surrounding the usage of quotes.


well, if you need a apostrophes in your string it would be wise to use quotation marks:

"i'm don't and so on"

if we would use apostrophes for string literal you would you need to escape the apostrophes you want to use in the string:

'i\'m don\'t and so on'

otherwise the string would end to early, it goes without saying that the first approach is preferable

same for when you want to use quotation marks in your string, use apostrophes for string literal, the rest is personal preference


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.