aboutsummaryrefslogtreecommitdiffstats
path: root/doc/syntax/exceptions.rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/syntax/exceptions.rdoc')
-rw-r--r--doc/syntax/exceptions.rdoc9
1 files changed, 8 insertions, 1 deletions
diff --git a/doc/syntax/exceptions.rdoc b/doc/syntax/exceptions.rdoc
index a2e75616fb..7fd58c83e8 100644
--- a/doc/syntax/exceptions.rdoc
+++ b/doc/syntax/exceptions.rdoc
@@ -17,7 +17,14 @@ wish to limit the scope of rescued exceptions:
# ...
end
-The same is true for a +class+ or +module+.
+The same is true for, +class+, +module+, and +block+:
+
+ [0, 1, 2].map do |i|
+ 10 / i
+ rescue ZeroDivisionError
+ nil
+ end
+ #=> [nil, 10, 5]
You can assign the exception to a local variable by using <tt>=>
variable_name</tt> at the end of the +rescue+ line: