[前][次][番号順一覧][スレッド一覧]

ruby-changes:26394

From: drbrain <ko1@a...>
Date: Tue, 18 Dec 2012 16:47:43 +0900 (JST)
Subject: [ruby-changes:26394] drbrain:r38445 (trunk): * doc/syntax/literals.rdoc: Used simplified heredoc example that

drbrain	2012-12-18 16:46:33 +0900 (Tue, 18 Dec 2012)

  New Revision: 38445

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38445

  Log:
    * doc/syntax/literals.rdoc:  Used simplified heredoc example that
      doesn't include method definition.  Added heredoc with backticks.

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/literals.rdoc

Index: doc/syntax/literals.rdoc
===================================================================
--- doc/syntax/literals.rdoc	(revision 38444)
+++ doc/syntax/literals.rdoc	(revision 38445)
@@ -127,16 +127,12 @@ typically used. https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L127
 
 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: https://github.com/ruby/ruby/blob/trunk/doc/syntax/literals.rdoc#L147
 
   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
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38444)
+++ ChangeLog	(revision 38445)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 18 16:46:15 2012  Eric Hodel  <drbrain@s...>
+
+	* 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@s...>
 
 	* lib/rdoc/store.rb:  Work around RDoc stores from older versions of

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]