[#62297] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap. — Eric Wong <normalperson@...>
nari@ruby-lang.org wrote:
7 messages
2014/05/02
[#62307] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— SASADA Koichi <ko1@...>
2014/05/03
(2014/05/03 4:41), Eric Wong wrote:
[#62402] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— Eric Wong <normalperson@...>
2014/05/05
SASADA Koichi <ko1@atdot.net> wrote:
[#62523] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — ko1@...
Issue #9632 has been updated by Koichi Sasada.
3 messages
2014/05/11
[#62556] doxygen (Re: Re: [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan) — Tanaka Akira <akr@...>
2014-05-11 8:50 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
3 messages
2014/05/13
[#62727] [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl — Eric Wong <normalperson@...>
rb_unlink_method_entry may cause old_me to be swept before the new
7 messages
2014/05/24
[#63039] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/10
Hi,
[#63077] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/10
SASADA Koichi <ko1@atdot.net> wrote:
[#63086] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/11
(2014/06/11 4:47), Eric Wong wrote:
[#63087] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/11
SASADA Koichi <ko1@atdot.net> wrote:
[#62862] [RFC] README.EXT: document rb_gc_register_mark_object — Eric Wong <normalperson@...>
Any comment on officially supporting this as part of the C API?
5 messages
2014/05/30
[ruby-core:62820] [ruby-trunk - Feature #9867] Introduce each/else block into ruby
From:
rr.rosas@...
Date:
2014-05-28 11:13:31 UTC
List:
ruby-core #62820
Issue #9867 has been updated by Rodrigo Rosenfeld Rosas.
Ah, now I see. Indeed it would be useful for templates processing. Since I =
barely write any ERB those days, that's probably the reason why I never nee=
ded something like that... For example, this is how I'd handle those cases =
usually in my methods:
~~~
(do_something_else; return) if array.empty?
array.each {...}
~~~
But even this is not that much common in my code. Way more common is the si=
tuation where a variable could be even an array or not be present (in which=
case I'd get nil). In such cases I often write code like:
~~~
(hash[:array] || []).each{...}
# or:
Array(hash[:array]).each{...}
~~~
But I can definitely see how your proposal would be useful for template lan=
guages, like ERB.
It's also interesting to point out that other people seem to be interested =
on a better approach for handling this case:
http://stackoverflow.com/questions/1027871/rails-an-elegant-way-to-display-=
a-message-when-there-are-no-elements-in-databas
Here's one suggested idiom for dealing with it that you might consider:
~~~
<% if @messages.each do |message| %>
<%# code or partial to display the message %>
<% end.empty? %>
You have no messages.
<% end %>
~~~
----------------------------------------
Feature #9867: Introduce each/else block into ruby
https://bugs.ruby-lang.org/issues/9867#change-46944
* Author: =C5=81ukasz Strzebi=C5=84czyk
* Status: Feedback
* Priority: Low
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version:=20
----------------------------------------
Hi
Code like this happens quite often:
if array.any?
array.each do |elem|
some_work
end
else
do_something_else
end
I was thinking if it was possible, to introduce syntax like this:
array.each do |elem|
some_work
else
do_something_else
end
where code in else would fire if array is empty. This would simplify a lot =
of code nicely and would be completely backwards compatible. Is that a good=
idea?
--=20
https://bugs.ruby-lang.org/