Is there a specific time when I should use "" vs ''?
I've been using single quotes most of the time because it's easier to type but I'm not sure if I should.
e.g. get 'user/new' vs. get "user/new"
Is there a specific time when I should use "" vs ''?
I've been using single quotes most of the time because it's easier to type but I'm not sure if I should.
e.g. get 'user/new' vs. get "user/new"
Another reason you would want to use single-quotes is when passing a regex pattern as a string:
This regex pattern will work because passed within single-quotes:
"123 ABC".match('\d')
=> #<MatchData "1">
This regex pattern will fail because passed within double-quotes (you would have to double-escape it to get it to work):
"123 ABC".match("\d")
=> nil