I would like to keep \n when I print out strings in ruby,
Like now, if I use puts or print, \n will end up with a newline:
pry(main)> print "abc\nabc"
abc
abc
is there a way to let ruby print it out like: abc\nabc ?
UPDATE
Sorry that maybe I didn’t make it more clear. I am debugging my regexps, so when I output a string, if a \n is displayed as a \n, not a newline, it would be easier for me to check. So @slivu ‘s answer is exactly what I want. Thanks guys.
i would suggest to use
pinstead ofputs/print:and in fact with
pryyou do not need to use any of them, just type your string and enter: