A heredoc is a Ruby string, usually multiline, written directly in the program file as a template or data block. The << operator reads text through the next matching delimiter, excluding that delimiter. section 8.1.1
Choose the form that matches the surrounding code:
- Use <<EOM or another delimiter for ordinary heredocs; the delimiter must otherwise stand alone and flush left. section 8.1.1
- Use <<-EOM when the terminating delimiter may be indented. section 8.1.1
- Use <<~EOM to strip leading whitespace, especially for heredocs nested inside method definitions. section 8.1.1
Indented messages
A squiggly heredoc keeps source indentation readable while removing that indentation from the resulting string. A hyphenated heredoc instead permits an indented terminator but preserves the content’s leading spaces.
