Friday, November 28, 2014

Escape sequence b

I'm currently reading the website (online e-book) Learn Ruby the Hard Way and I'm on exercise 10.

It covers using the escape sequence with the various options.

I was stuck for a moment on why it wasn't working like I thought it should.

2.1.3 :001 > puts "backspace\b"
backspace
 => nil

I felt the entry should have removed the 'e' but the 'e' still showed up.  On another attempt, I got the result I was looking for.

2.1.3 :002 > puts "backspace\b "
backspac
 => nil

Putting a space between the letter 'b' and the double quote worked.  I have no technical explanation for this. My guess is that the backslash b is not given any space to "do it's thing".  I've googled but couldn't find anything on this topic.  Any comments welcome.  If I do find the explanation, I'll post what I find.

No comments:

Post a Comment