From: Robert Klemme Date: 2010-01-25T18:49:02+09:00 Subject: Re: how to represent a single backslash? 2010/1/25 Xavier Noëlle : > irb(main):001:0> puts "\\" > \ > => nil > irb(main):002:0> puts '\\' > \ > => nil > > There is a difference between what is written in your code and what > the output will be. > "\\" is not the same as "\", which is why irb prints the string > constant as you entered it. But if you print it, it will output what > you expected, i.e. a backslash. Right. Additional explanation: the reason for this is that IRB by default uses #inspect - the same method that #p uses for printing: irb(main):007:0> s = "a" => "a" irb(main):008:0> puts s a => nil irb(main):009:0> p s "a" => "a" irb(main):010:0> puts s.inspect "a" => nil irb(main):011:0> s => "a" irb(main):012:0> Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/