path: root/doc/syntax
diff options
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-15 18:06:24 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-15 18:06:24 +0000
commitd902101b32c4efb487559ab91a48cb1fe28f1ae9 (patch)
treea8debb16163291e16011270fe4f65c3a0cbe2c7d /doc/syntax
parenteaab306b59c4a1905b67ff989339938d8ab67fe9 (diff)
* doc/syntax/control_expressions.rdoc (redo Statement): Added note
about retry. * doc/syntax/exceptions.rdoc: Added retry statement git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'doc/syntax')
2 files changed, 22 insertions, 0 deletions
diff --git a/doc/syntax/control_expressions.rdoc b/doc/syntax/control_expressions.rdoc
index 8523aea..fe1a5fd 100644
--- a/doc/syntax/control_expressions.rdoc
+++ b/doc/syntax/control_expressions.rdoc
@@ -397,3 +397,8 @@ Use +redo+ to redo the current iteration:
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+.
diff --git a/doc/syntax/exceptions.rdoc b/doc/syntax/exceptions.rdoc
index 390eb86..0efc35a 100644
--- a/doc/syntax/exceptions.rdoc
+++ b/doc/syntax/exceptions.rdoc
@@ -55,6 +55,23 @@ The exception is matched to the rescue section starting at the top, and matches
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
To always run some code whether an exception was raised or not, use +ensure+: