mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* doc/syntax/control_expressions.rdoc (redo Statement): Added note
about retry. * doc/syntax/exceptions.rdoc: Added retry statement git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
eaab306b59
commit
d902101b32
3 changed files with 28 additions and 0 deletions
|
@ -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
|
||||
details.
|
||||
|
||||
To always run some code whether an exception was raised or not, use +ensure+:
|
||||
|
||||
begin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue