Skip to content

Instantly share code, notes, and snippets.

@tsevdos
Created September 13, 2015 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsevdos/05580fce12c1cd6fe118 to your computer and use it in GitHub Desktop.
Save tsevdos/05580fce12c1cd6fe118 to your computer and use it in GitHub Desktop.
Ruby tips : Here Documents
name = 'John'
# default acts as double-quoted string
puts <<heredoc
Hello #{name}
other line 1,
other line 2.
heredoc
# double-quoted string
puts <<"double-quoted"
Hello #{name}
other line 1,
other line 2.
double-quoted
# single-quoted string (string interpolation won't work on the below example)
puts <<'single-quoted'
Hello #{name}
other line 1,
other line 2.
single-quoted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment