Project

General

Profile

Actions

Feature #12623

closed

rescue in blocks without begin/end

Added by Nondv (Dmitry Non) over 7 years ago. Updated over 2 years ago.

Status:
Closed
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 2 (0 open2 closed)

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0