[#76442] [Ruby trunk Feature#11741] Migrate Ruby to Git from Subversion — naruse@...
Issue #11741 has been updated by Yui NARUSE.
3 messages
2016/07/19
[#76515] [Ruby trunk Bug#12610] webrick: protect from httpoxy — nagachika00@...
Issue #12610 has been updated by Tomoyuki Chikanaga.
3 messages
2016/07/22
[ruby-core:76572] [CommonRuby Feature#12623] rescue in blocks without begin/end
From:
non.dmitriy@...
Date:
2016-07-26 13:00:57 UTC
List:
ruby-core #76572
Issue #12623 has been updated by Dmitriy Non.
> An objection is that rescue in {} block feels weird.
Do you mean in one-line or multi-line form?
Multiline:
~~~ruby
list.each { |x|
# do something
rescue
# do something
}
~~~
In single-line there's ambiguous case:
~~~ruby
# not implemented
list.each { |x| action_1; action_2; rescue; 'error!' }
# this is valid
list.each { |x| action_1; action_2 rescue 'error!' }
~~~
But 2nd line looks bad anyway :(
So, what's problem of "feels weird"?
IMHO there're not many people that will use it like that (my first example in single-line).
----------------------------------------
Feature #12623: rescue in blocks without begin/end
https://bugs.ruby-lang.org/issues/12623#change-59799
* Author: Dmitriy Non
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
Hi there!
There's pretty nice feature that we can use "short rescue" in method definitions:
~~~ruby
def my_method
raise '1234'
rescue
puts 'rescued'
end
~~~
What about using this in blocks?
~~~ruby
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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>