Project

General

Profile

Feature #12623

rescue in blocks without begin/end

Added by Nondv (Dmitry Non) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:76550]

Description

Hi there!

There's pretty nice feature that we can use "short rescue" in method definitions:

def my_method
  raise '1234'
rescue
   puts 'rescued'
end

What about using this in blocks?

loop do
  n = enumerator.next
  # do something
rescue StopIteration
end

P.S. actually I am not sure if this FR was not created earlier but I couldn't google it.
P.P.S sorry for my english


Related issues

Is duplicate of Ruby master - Feature #7882: Allow rescue/else/ensure in do..endClosedmatz (Yukihiro Matsumoto)Actions
Has duplicate Ruby master - Feature #12906: do/end blocks work with ensure/rescue/elseClosednobu (Nobuyoshi Nakada)Actions

Also available in: Atom PDF