A delimiter marks where a Ruby literal begins and ends. In percent-style strings, the opening delimiter must match its closing counterpart: paired braces may use left/right forms, while other nonalphanumeric delimiters appear twice. section 8.1.1
Choosing a delimiter
%q-A string- %Q/Another string/ %[Yet another string] With paired delimiters, Ruby tracks nested braces. Thus %Q{I can put {} in here unescaped.} works, while an unmatched brace of the delimiter type must be escaped. section 8.1.1
Heredocs use an identifier as the delimiter: <<EOM starts the body, and a later EOM ends it. The closing identifier can be flush left, or, with <<-EOM, indented; <<~EOM additionally removes common indentation. section 8.1.1
Delimiters also affect how literal content is written:
- %q and <<-'EOM' produce non-interpolating string forms, preserving interpolation text literally. section 8.1.1
- A heredoc can appear as an argument, array element, or expression, so its delimiter marks a value within larger Ruby code. section 8.1.1
%q-A string-
%Q/Another string/
%[Yet another string]
Compare several valid percent-string delimiter styles. section 8.1.1










