ruby coding convention for single or double quoting your strings -


i had around couldn't find convention on how use quotes strings, know difference between two, everywhere see code double quotes singles enough, therefor can't recognize pattern. i'm asking because i'd start contributing opensource (not writing code of course) , i'd habit since beginning. rather use single quotes as possible (also enstrong confidence difference between two).

and way addendum on html great... (something <div class='ok'/>)

thanks that

i don't think there strong convention within entire community. have seen, there seems bias towards ignoring single quotes altogether , using double quotes. in circles, is convention, localized one, not 1 whole community.

personally, whenever have several different ways express same thing, tend use different ways convey different semantics. (for example, use curly braces vs. do/end in blocks distinguish between blocks used side effects , blocks used return value.)

so, use double quotes when actually want use string interpolation or escaping, otherwise use single quotes. way, when see string can tell there's no funny business going on, , there's no code hidden inside of it.

i pragmatic, though. prefer "it's string!" on 'it\'s string!' or %q[it's string!].


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -