Percent-style string notation creates Ruby strings with a percent sign, an optional mode character, and a delimiter: %q produces single-quoted behavior, while %Q and plain %{...} produce double-quoted behavior. section 8.1.1
Choose the form that makes the string easiest to read:
- %q{You needn't escape apostrophes or quotation marks.} section 8.1.1
- %Q{The result is #{2 + 2}} and %{The result is #{2 + 2}} both allow interpolation and double-quoted escapes. section 8.1.1
- Curly braces are common, but paired brackets or repeated nonalphanumeric delimiters also work: %q-A string- and %Q/Another string/. section 8.1.1
%q-A string-
%Q/Another string/
%[Yet another string]
Compare several valid delimiters without changing the basic percent-style notation. section 8.1.1
