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

ruby-changes:26788

From: drbrain <ko1@a...>
Date: Wed, 16 Jan 2013 03:06:37 +0900 (JST)
Subject: [ruby-changes:26788] drbrain:r38840 (trunk): * doc/syntax/control_expressions.rdoc (redo Statement): Added note

drbrain	2013-01-16 03:06:24 +0900 (Wed, 16 Jan 2013)

  New Revision: 38840

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

  Log:
    * doc/syntax/control_expressions.rdoc (redo Statement):  Added note
      about retry.
    * doc/syntax/exceptions.rdoc:  Added retry statement

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/control_expressions.rdoc
    trunk/doc/syntax/exceptions.rdoc

Index: doc/syntax/exceptions.rdoc
===================================================================
--- doc/syntax/exceptions.rdoc	(revision 38839)
+++ doc/syntax/exceptions.rdoc	(revision 38840)
@@ -55,6 +55,23 @@ The exception is matched to the rescue s https://github.com/ruby/ruby/blob/trunk/doc/syntax/exceptions.rdoc#L55
 only once.  If an ArgumentError is raised in the begin section it will not be
 handled in the StandardError section.
 
+You may retry rescued exceptions:
+
+  begin
+    # ...
+  rescue
+    # do something that may change the result of the begin block
+    retry
+  end
+
+Execution will resume at the start of the begin block, so be careful not to
+create an infinite loop.
+
+Inside a rescue block is the only valid location for +retry+, all other uses
+will raise a SyntaxError.  If you wish to retry a block iteration use +redo+.
+See {Control Expressions}[rdoc-ref:syntax/control_expressions.rdoc] for
+details.
+
 To always run some code whether an exception was raised or not, use +ensure+:
 
   begin
Index: doc/syntax/control_expressions.rdoc
===================================================================
--- doc/syntax/control_expressions.rdoc	(revision 38839)
+++ doc/syntax/control_expressions.rdoc	(revision 38840)
@@ -397,3 +397,8 @@ Use +redo+ to redo the current iteration https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L397
 
 This prints [0, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11]
 
+In Ruby 1.8 you could also use +retry+ where you used +redo+.  This is no
+longer true, now you will receive a SyntaxError when you use +retry+ outside
+of a +rescue+ block.  See {Exceptions}[rdoc-ref:syntax/exceptions.rdoc]
+for proper usage of +retry+.
+
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38839)
+++ ChangeLog	(revision 38840)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 16 03:05:50 2013  Eric Hodel  <drbrain@s...>
+
+	* doc/syntax/control_expressions.rdoc (redo Statement):  Added note
+	  about retry.
+	* doc/syntax/exceptions.rdoc:  Added retry statement
+
 Tue Jan 15 23:12:34 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* tool/vpath.rb (VPath#list): default separator to PATH_SEPARATOR from

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

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