开发者

When to use single vs. double quotes in a Rails app [duplicate]

This question already has answers开发者_Python百科 here: Closed 12 years ago.

Possible Duplicate:

Which style of Ruby string quoting do you favour?

Is there a good rule of thumb about when to use single or double quotes in ruby, and especially rails apps?

Doesn't one use more memory than the other? Is there any sort of convention the rails community has settled on?


The difference between using double quotes versus single quotes is that double quotes interpret escaped characters and single quotes preserve them.

Here is an example

 puts "i \n love \n ruby"
 #i 
 #love 
 #ruby

and

 puts 'i \n love \n ruby'
 #i \n love \n ruby
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜