Created
September 13, 2015 11:03
-
-
Save tsevdos/05580fce12c1cd6fe118 to your computer and use it in GitHub Desktop.
Ruby tips : Here Documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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