multiline_string = <<~EOM
This is a
multiline
string
in Ruby
EOM
Explanation:
- The
<<~EOM
syntax is used to start a multiline string in Ruby. - The
EOM
serves as the delimiter to mark the end of the multiline string. - The
<<~
operator allows the indentation of the ending delimiter to be ignored within the string. - The lines of text between the starting and ending delimiters are combined into a single string, including any line breaks and indentation.
- This allows for the creation of a string that spans multiple lines without the need for explicit escape characters or concatenation operators.
- The resulting
multiline_string
variable contains the entire multiline string, including the line breaks and indentation.