From: "Jesús Gabriel y Galán" Date: 2010-01-25T18:34:17+09:00 Subject: Re: how to represent a single backslash? On Mon, Jan 25, 2010 at 9:55 AM, lalawawa wrote: > How do a put a single backslash into a string in Ruby? > > irb(main):006:0> '\' > irb(main):007:0' ' > => "'\n" > irb(main):008:0> '\\' > => "\\" > irb(main):009:0> > > in 6, the backslash escapes the ending ', which is not what I wanted. In 8, > the double backslash becomes two backslashes, which is not what I wanted > either. > I get exactly the same problem with double quotes. It's not 2 backslashes, just one. Irb shows you two because it's the representation of the inspected string: irb(main):003:0> '\\' => "\\" irb(main):004:0> '\\'.size => 1 irb(main):005:0> puts '\\' \ => nil Jesus.