zaagan
12/11/2019 - 3:48 PM

Ruby Basics - Here Document

Ruby Basics - Here Document

print <<EOF
   This is the first way of creating
   here document ie. multiple line string.
EOF

print <<"EOF";                # same as above
   This is the second way of creating
   here document ie. multiple line string.
EOF

print <<`EOC`                 # execute commands
	echo hi there
	echo lo there
EOC

print <<"foo", <<"bar"  # you can stack them
	I said foo.
foo
	I said bar.
bar

# Output :
#    This is the first way of creating
#    her document ie. multiple line string.
#    This is the second way of creating
#    her document ie. multiple line string.
# hi there
# lo there
#       I said foo.
#       I said bar.