Skip to content

Instantly share code, notes, and snippets.

@ericallam
Created September 14, 2011 14:05
Show Gist options
  • Save ericallam/1216646 to your computer and use it in GitHub Desktop.
Save ericallam/1216646 to your computer and use it in GitHub Desktop.
Ruby Heredocs
# 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