A squiggly heredoc, written <<~, creates a multiline string while removing leading whitespace from each content line. It is especially useful inside indented method definitions, where ordinary indentation would otherwise become part of the string. section 8.1.1
Indented method output
class RubyWelcomeWagon def squiggly_message <<~EOM Welcome to the world of Ruby! We're happy you're here! EOM end end RubyWelcomeWagon.new.squiggly_message # => "Welcome to the world of Ruby!\nWe're happy you're here!\n"
Compare the related heredoc forms:
- <<~ permits readable source indentation and removes leading whitespace from the message. section 8.1.1
