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.
精彩评论