Created
September 14, 2011 14:05
-
-
Save ericallam/1216646 to your computer and use it in GitHub Desktop.
Ruby Heredocs
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
# by default, heredoc strings are treated like double-quoted ruby strings, which means you can do string interpolation: | |
<<-EOF | |
The time is #{Time.now} | |
EOF | |
# => The time is Wed Sep 14 10:04:29 -0400 2011 | |
# But you can create heredoc strings that are treated like single-quoted string, like this: | |
<<-'EOF' | |
The time is #{Time.now} | |
EOF | |
# => The time is #{Time.now} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment