Skip to content

Instantly share code, notes, and snippets.

@KellyMahan
Created September 11, 2012 14:36
Show Gist options
  • Select an option

  • Save KellyMahan/3699188 to your computer and use it in GitHub Desktop.

Select an option

Save KellyMahan/3699188 to your computer and use it in GitHub Desktop.
What I learned today
#something i learned today that I didn't know was possible in ruby.
array_of_long_pasted_in_strings = [<<FOO, <<BAR, <<BLATZ]
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
FOO
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
BAR
I recently discovered that I can use multiple heredocs as parameters.
Isn't that neat? Because almost nothing needs to be escaped with heredocs, I prefer to use it when strings are pasted in from elsewhere. Because the syntax for using it inside parameter lists is so nice, I prefer to use it whenever a multiline string literal is being passed into something as an argument.
BLATZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment