summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-18 07:46:33 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-18 07:46:33 +0000
commitaa233d3f3331c266baabfefc68d9bc2cc2f4fd0b (patch)
tree2d359af9130bcf55b2d475ebd253b37679208e3c /doc
parent69dfd5e034188e20bc12c8a5dcb62694f52295a7 (diff)
* doc/syntax/literals.rdoc: Used simplified heredoc example that
doesn't include method definition. Added heredoc with backticks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'doc')
-rw-r--r--doc/syntax/literals.rdoc12
1 files changed, 8 insertions, 4 deletions
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index a17f51bd5a..61743f7906 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -127,16 +127,12 @@ typically used.
You may indent the ending identifier if you place a "-" after <tt><<</tt>:
- def test_something
expected_result = <<-INDENTED_HEREDOC
This would contain specially formatted text.
That might span many lines
INDENTED_HEREDOC
- # ...
- end
-
Note that the while the closing identifier may be indented, the content is
always treated as if it is flush left. If you indent the content those spaces
will appear in the output.
@@ -151,6 +147,14 @@ quotes:
p expected_result # prints: "One plus one is \#{1 + 1}\n"
+The identifier may also be surrounded with double quotes (which is the same as
+no quotes) or with backticks. When surrounded by backticks the HEREDOC
+behaves like Kernel#`:
+
+ puts <<-`HEREDOC`
+ cat #{__FILE__}
+ HEREDOC
+
To call a method on a heredoc place it after the opening identifier:
expected_result = <<-EXPECTED.chomp