2006/5/19, Krekna Mektek <krekna / gmail.com>:
> Can someone help me out with this, I can't put the string 'a\b\c' in
> the variable str, which is strange, because I am working with the
> PickAxe book, and this what should work (page 71, 2nd ed.)
>
> the two before seem to work, but the example in the book, 'a\b\c' seems not.
> This a bug? How come irb does not seem to understand the last quote?
>
> irb(main):021:0> str = 'a\b\c '
> => "a\\b\\c "
> irb(main):022:0> str = 'a\bc'
> => "a\\bc"
> irb(main):023:0> str = 'a\b\c'
> irb(main):024:0'
> irb(main):025:0' '
> SyntaxError: compile error
> (irb):25: unterminated string meets end of file
>         from (irb):25
>         from :0

>> str = 'a\\b\\c'
=> "a\\b\\c"
>> puts str
a\b\c
=> nil

Note that irb uses inspect - this is sometimes confusing as it will
print a double backslash for a single backslash in the string.

Kind regards

robert

-- 
Have a look: http://www.flickr.com/photos/fussel-foto/