4 ms·
Eh, many programming languages use double quotes for strings, and single quotes for singular characters. Languages that can use single quotes for strings that
by woolvalley 8y ago
Eh, many programming languages use double quotes for strings, and single quotes for singular characters. Languages that can use single quotes for strings that I know of are ruby and python.
- ciupicri 8y agoAlso Pascal and SQL.
- samatman 8y agoLua, and there are others. I favor double quotes for this same reason even when single quotes are allowed. I'd like «guillemets» but that's going to have to be self-serve...
- spc476 8y agoI use single quotes when the string in question is used like an enumeration: set_color('black','white') And double quotes for strings meant to be read by a human: print("Hello there. How are you?") And an example with both forms: syslog('warning',"unit %s spin rate %f too low",u,rate) For me, it's an indication of how I expect the string to be used.
- Inityx 8y agoAnd even then, Perl and Ruby (heck, even Bash) have a semantic difference between double- and single-quoted strings. The only other popular general-purpose languages where they're synonymous are PHP, JavaScript, and Lua.
- ComputerGuru 8y ago>The only other popular general-purpose languages where they're synonymous are PHP, JavaScript, and Lua. PHP does treat single and double quotes differently. Contents of single quotes strings are not parsed for variable substitution.
- ComputerGuru 8y agoDon’t forget VimL, the language that insanely decided to use double quotes as a “start of comment” indicator, then went back and gave them special meaning based on their position so they either signal the start of a comment or a string.
- prawl 8y agoA different comment character could have been chosen, but this affects nothing. It's not insane.
- zestyping 8y agoAnd JavaScript!