开发者

Single quoted Ruby strings -- inconsistent escaping

Why do the following strings give me the same output in the Ruby interpreter?

  'f:\new'
  'f:\\new'

Both strings result in: "f:\\new". I was expecting the second string to display "f:\\\\new开发者_如何转开发" (if not that, then the first one should have shown "f:\new")


Single-quoted strings support only two escape sequences: \' and \\

That's why in your first example \n is not treated as new-line char: it's not in the list.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜