mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
69dfd5e034
commit
aa233d3f33
2 changed files with 13 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Tue Dec 18 16:46:15 2012 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* doc/syntax/literals.rdoc: Used simplified heredoc example that
|
||||
doesn't include method definition. Added heredoc with backticks.
|
||||
|
||||
Tue Dec 18 16:38:51 2012 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/store.rb: Work around RDoc stores from older versions of
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue