Here document
用于引入一段较复杂的内容,其中包括了可能出现的各种字符
语法
以<< 或<<- 开头,后面紧跟一个标识其结尾的字符或字符串。下一行 开始表示引入的字符内容,遇到结束符时表示,引入的内容结束
简单的:
document = <<HERE
This is a string literal.
It has two lines and abruptly ends...
HERE
引入两个document
greeting = <<HERE + <<THERE + "World"
Hello
HERE
There
THERE
结果:Hello There World
空的document
empty = <<END
END
使用字符串作为标识
document = <<'THIS IS THE END, MY ONLY FRIEND, THE END'
...
...
...
...
'THIS IS THE END, MY ONLY FRIEND, THE END'