views:

42

answers:

1

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")

+2  A: 

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.

Nikita Rybak