Ruby Newbie here. I do not understand why Ruby looks inside
%q and escapes the
I am using Ruby to generate Latex code. I need to generate
\\\hline which is used in Latex for table making. I found
\\\hline as input generated
\hline even though the string was inside
Here is MWE
#!/usr/local/bin/ruby -w tmp = File.open('foo.txt','w') str = %q[\\\hline] tmp.write(str) tmp.close
foo.txt has this
Ruby does give the warning
warning: encountered \r in middle of line, treated as a mere space
But this should not be generated since this is supposed to be escaped strings?
Now I tried it with Python multiline raw strings (similar to Ruby's
file = open('foo4.txt', 'w') str = r"""\\\hline""" file.write(str) file.close()
And the file again contains
\\\hline as expected.
Am I doing something wrong in Ruby?
ruby -v ruby 2.2.2p95 (2015-04-13 revision 50295) [i686-linux]