Project

General

Profile

Actions

Feature #7882

closed

Allow rescue/else/ensure in do..end

Added by Anonymous almost 12 years ago. Updated almost 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:52513]

Description

The keywords rescue, else and ensure can be used when defining methods like so:

def foo
  #
rescue
  #
else
  #
ensure
  #
end

However when using a block delimited by do..end, you must use begin..end as well:

foo do
  begin
    # ...
  rescue
    # ...
    # ...
  end
end

It would be nice to be able to drop the extra begin..end and use rescue, etc. clauses directly:

foo do
  # ...
rescue
  # ...
  # ...
end

I cannot think of any ambiguities this syntax would cause, but please correct me if I am wrong.


Related issues 3 (0 open3 closed)

Has duplicate Ruby master - Feature #11337: Allow rescue without begin inside blocksClosedmatz (Yukihiro Matsumoto)Actions
Has duplicate Ruby master - Feature #12623: rescue in blocks without begin/endClosedActions
Has duplicate Ruby master - Feature #12906: do/end blocks work with ensure/rescue/elseClosednobu (Nobuyoshi Nakada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0