Which style of Ruby string quoting do you favour?

后端 未结 9 1812
挽巷
挽巷 2020-11-30 00:31

Which style of Ruby string quoting do you favour? Up until now I\'ve always used \'single quotes\' unless the string contains certain escape sequences or interp

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 01:11

    I always use single quotes unless I need interpolation.

    Why? It looks nicer. When you have a ton of stuff on the screen, lots of single quotes give you less "visual clutter" than lots of double quotes.

    I'd like to note that this isn't something I deliberately decided to do, just something that I've 'evolved' over time in trying to achieve nicer looking code.

    Occasionally I'll use %q or %Q if I need in-line quotes. I've only ever used heredocs maybe once or twice.

提交回复
热议问题