Recall & Review
beginner
What is heredoc syntax in Ruby?
Heredoc syntax allows you to create multiline strings easily by using << followed by an identifier, then the string content, and ending with the same identifier on its own line.
Click to reveal answer
beginner
How do you start a heredoc string in Ruby?
You start a heredoc string with << followed by an identifier, for example <
Click to reveal answer
beginner
How do you end a heredoc string in Ruby?
You end a heredoc string by placing the same identifier used to start it on its own line, with no extra spaces or characters.
Click to reveal answer
intermediate
What is the difference between <
<
Click to reveal answer
intermediate
How can you create a heredoc string that does not process escape sequences or interpolation?
Use single quotes around the identifier like <<'EOF'. This creates a literal string where escape sequences and interpolation are not processed.
Click to reveal answer
Which of the following correctly starts a heredoc string in Ruby?
✗ Incorrect
Heredoc strings start with << followed by an identifier like TEXT.
How must the ending identifier of a heredoc appear when using <
✗ Incorrect
The ending identifier must be at the start of the line with no spaces when using <
What does <<-'EOF' do differently than <
✗ Incorrect
<<-EOF allows the ending identifier to be indented, making code formatting easier.
How do you create a heredoc string that treats content literally (no interpolation or escape sequences)?
✗ Incorrect
Using single quotes around the identifier like <<'EOF' creates a literal string.
What will this Ruby code output?
str = <
✗ Incorrect
Heredoc with <
Explain how to write a multiline string using heredoc syntax in Ruby.
Think about how you mark the start and end of the string.
You got /3 concepts.
Describe the difference between <
Focus on indentation and string processing differences.
You got /3 concepts.