I wonder if anyone has come up with a shortcut to correctly
convert ALL single quotes to double quotes in a new rails project. Thank you in advance. I would do that at the end of generating new project with a template.rb
Use the String. replace() method to replace double with single quotes, e.g. const replaced = str. replace(/"/g, "'"); . The replace method will return a new string where all occurrences of double quotes are replaced with single quotes.
Single-quoted and double-quoted strings are (almost) equivalent in Ruby. Of course, you have to escape \' inside single-quoted strings and \" inside double-quoted strings.
The short answer is that it depends on the country that you are writing in. In British and Australian English, one typically uses single quotes. If you're writing in North America, double quote marks are typically used.
Use the CHAR functionYou can also insert a double quote in an Excel formula using the CHAR function.
I would also use rubocop
for that:
rubocop --safe-auto-correct --only "Style/StringLiterals" .
As spickermann
suggested
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With