From: Adam Keys Date: 2005-04-22T20:44:12+09:00 Subject: Re: for .. in .. else? On Apr 21, 2005, at 5:46 PM, Hal Fulton wrote: > FWIW I'll offer this (untested) alternative: > > > > <% unless song_list.each do |song|%> > > <% end.empty? %> > > <% end %> > >
Songs
<%= song.name %>
no songs!
A few weeks ago I was on a crusade to not create temporary Arrays and Hashes. I wrote a bit of code something like this: ary.reject do |item| item.some_predicate? end.each do |doodad| doodad.do_something end I was showing it to a non-Rubyist and he thought it was a little hard to read. I agreed it may be a little too clever for its own good. Obviously Hal doesn't think so :). Does anyone else have strong feelings on code like the above? -- ~akk http://therealadam.com