I encountered a rather peculiar behavior of strings today.
Here is my irb session:
SyntaxError: compile error
(irb):2: unterminated string meets end of file
As you can see when I typed ‘ab\c’ my irb didn’t return. It was
expecting some thing more. Then I typed a single quote ( ’ ) to
terminate the string and it gave me this SyntaxError. The same thing
happens even I type ‘ab\c’
I was trying this after reading section 126.96.36.199 of “The Ruby
Programming Language”. This is what it says about backslashes in
single quoted strings:
"In single-quoted strings, a backslash is not special if the character
that follows it is anything other than a quote or a backslash. "
But at the same time if I type ‘a\b’ it returns ‘a\b’ which is inline
with the book. Any ideas what’s happening here?