[ruby-core:76790] [Ruby trunk Feature#7882] Allow rescue/else/ensure in do..end
From:
nobu@...
Date:
2016-08-09 09:06:41 UTC
List:
ruby-core #76790
Issue #7882 has been updated by Nobuyoshi Nakada.
Description updated
----------------------------------------
Feature #7882: Allow rescue/else/ensure in do..end
https://bugs.ruby-lang.org/issues/7882#change-60014
* Author: Charlie Somerville
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
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>