From: MonkeeSage Date: 2007-12-18T02:40:15+09:00 Subject: Re: Backslashes in Command Line Arguments On Dec 17, 11:05 am, Joseph Pecoraro wrote: > > No, it's because you are using p instead of puts. > > > The p method prints the result of sending the inspect message to its > > argument, and String#inspect produces a what ruby string literal to > > represent the string looks like, and since \ is the escape character > > in ruby string literals it needs to be escaped itself in the output > > of inspect. > > > -- > > Rick DeNatale > > I purposely used p instead of puts for that exact reason. Which is how > I noticed that if you send "\n" Ruby does not get a newline character, > it gets a backslash n literal. > > Joe > -- > Posted viahttp://www.ruby-forum.com/. It does get a newline character...try looking at "\n"[0] (or if you're using 1.9, "\n".ord)...you'll notice it's the ascii ordinal 10...aka "newline". That was Robert's point. #inspect (and by proxy #p) represent non-printing characters as their escaped symbols so that you can actually see them. Try entering this in irb and notice the difference betwen the input string and that printed by #p... p "hello\x09there" Regards, Jordan