What is the use case for Ruby's %q / %Q quoting methods?

前端 未结 5 1117
一向
一向 2020-12-02 08:44

I\'ve been reading through Thomas\' Programming Ruby 1.9 and came upon the alternative delimited single and double-quoting methods (%q / %Q). I\'ve known of the

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 09:25

    They are useful when your string contains single- or double- quotes. This doesn't happen all that often, but the technique is very useful when it does.

提交回复
热议问题