Is there support in Ruby for (for lack of a better word) non-escaped (verbatim) strings?
Like in C#:
@"c:\Program Files\"
...or in Tcl:
{c:\Program Files\}
Is there support in Ruby for (for lack of a better word) non-escaped (verbatim) strings?
Like in C#:
@"c:\Program Files\"
...or in Tcl:
{c:\Program Files\}
Yes, you need to prefix your string with %
and then a single character delineating its type.
The one you want is %q{c:\program files\}
.
The pickaxe book covers this nicely here, section is General Delimited Input.
This has a couple examples that may be what you are looking for: Ruby Syntax
Besides %q{string}, you can also do the following:
string =<<SQL
SELECT *
FROM Book
WHERE price > 100.00
ORDER BY title;
SQL
The delimiters are arbitrary strings, conventionally in uppercase.
mystring = %q["'\t blahblahblah]
Or if you want to interpret \t
as tab:
mystring = %Q["'\t blahblahblah]
You can just use a single quoted string.
>> puts "a\tb"
a b
=> nil
>> puts 'a\tb'
a\tb
=> nil