T
Thorsten Müller
Hi all,
that's just an idea I came up with and thought worth a discussion.
Would it be possible to give each an else part?
For Rails programmers it is very common to do something like this:
In controller search for records:
@orders = Order. findall)
In view:
<% unless @orders.empty? then %>
<% @orders.each do |order| %>
<%= output order somehow %>
<% end %>
<% else %>
output message, that there are no orders
<% end %>
If each would have it's own else which runs if the
used array, enumerable or whatever is empty,
that code could look much nicer:
<% @orders.each do |order| %>
<%= output order somehow %>
<% else %>
output message, that there are no orders
<% end %>
I guess, that would be true for any other Ruby code, too.
Please give your opinions to that idea and if you think
there would be a chance to get this implemented one day...
that's just an idea I came up with and thought worth a discussion.
Would it be possible to give each an else part?
For Rails programmers it is very common to do something like this:
In controller search for records:
@orders = Order. findall)
In view:
<% unless @orders.empty? then %>
<% @orders.each do |order| %>
<%= output order somehow %>
<% end %>
<% else %>
output message, that there are no orders
<% end %>
If each would have it's own else which runs if the
used array, enumerable or whatever is empty,
that code could look much nicer:
<% @orders.each do |order| %>
<%= output order somehow %>
<% else %>
output message, that there are no orders
<% end %>
I guess, that would be true for any other Ruby code, too.
Please give your opinions to that idea and if you think
there would be a chance to get this implemented one day...