Skip to content

Instantly share code, notes, and snippets.

@langsharpe
Created August 30, 2021 04:07
Show Gist options
  • Save langsharpe/71734384eb6914708563159358d0349d to your computer and use it in GitHub Desktop.
Save langsharpe/71734384eb6914708563159358d0349d to your computer and use it in GitHub Desktop.
Ruby Heredoc Syntax for String Literals
# The one you want is
def method
string = <<~END
This format allows you to indent the contents of the string without including the indent in the value.
String interpolation works here.
END
string2 = <<~'END'
The single quotes around END prevent string interpolation here. It's also good for \_ ascii art _/ .
END
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment