Issue #7882 has been updated by Nobuyoshi Nakada.

Status changed from Assigned to Closed

----------------------------------------
Feature #7882: Allow rescue/else/ensure in do..end
https://bugs.ruby-lang.org/issues/7882#change-62853

* Author: Charlie Somerville
* Status: Closed
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Target version: 
----------------------------------------
The keywords `rescue`, `else` and `ensure` can be used when defining methods like so:

```ruby
def foo
  #
rescue
  #
else
  #
ensure
  #
end
```

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

```ruby
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:

```ruby
foo do
  # ...
rescue
  # ...
  # ...
end
```

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




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>