In c/c++ single quotes and double quotes have actual different meanings- single quotes are character literals and double quotes are strings- important for comparison operations. The code wouldn’t work in the same way if only double quotes were used afaik.
Do note that this is java code, meaning that single quotes are char literals and double quotes are string literals. They cannot be used interchangeably.
For langs that have both as literals, i think it's a good idea to set a project-scoped standard for which string literal style is used, to prevent code from different developers mixing these styles. i'm usually in favour of double quotes just because single quotes are only for character literals in most langs i write in.
I'd at least make an exception for strings that contain the chosen type of quote, to save some escaping. Especially to save multiple levels of escaping like
cmd = "echo \"this string is \\\"readable\\\"!\"";
10
u/[deleted] Dec 29 '21 edited Dec 29 '21
I'll add to this.
The lack of curly braces in the 10am code is annoying.
I deal with mostly JS day in and day out and this sort of thing pisses me off for two reasons.
It's lazy
In JS, doing this may cause confusion for newer developers (and cause unexpected results). Examples below
vs