October 2006
Intermediate to advanced
888 pages
16h 55m
English
Sometimes we want to represent strings that are rich in metacharacters such as single quotes, double quotes, and more. For these situations, we have the %q and %Q notations. Following either of these is a string within a pair of delimiters; I personally favor square brackets ([]).
The difference between the %q and %Q variants is that the former acts like a single-quoted string, and the latter like a double-quoted string.
S1 = %q[As Magritte said, "Ceci n'est pas une pipe."] s2 = %q[This is not a tab: (\t)] # same as: 'This is not a tab: \t' s3 = %Q[This IS a tab: (\t)] # same as: "This IS a tab: \t"
Both kinds of notation can be used with different delimiters. Besides brackets, there are other ...
Read now
Unlock full access