[ruby-core:76561] [CommonRuby Feature#12623] rescue in blocks without begin/end

From: rr.rosas@...
Date: 2016-07-25 18:18:52 UTC
List: ruby-core #76561
Issue #12623 has been updated by Rodrigo Rosenfeld Rosas.


+1, I often want this and never understood why it only worked with methods.

----------------------------------------
Feature #12623: rescue in blocks without begin/end
https://bugs.ruby-lang.org/issues/12623#change-59789

* Author: Dmitriy Non
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
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



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

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

In This Thread

Prev Next