From: dblack@... Date: 2006-03-02T23:18:06+09:00 Subject: Re: cleaner Ruby in a rails view Hi -- On Thu, 2 Mar 2006, petermichaux@yahoo.com wrote: > is something like the following acceptable? > > > <% ( item.cart_item_option_values || [] ).each do |ov| %> > > <% end %> If you get the right-hand side of that, it means the left-hand side was nil or false -- in which case calling #empty? on it will raise an error. (Actually in your original post you had _values once and _variations once, but I'm assuming that was an error.) On the other hand, if you're sure you can call #empty? on it, that suggests you know it will be an array, in which case you can just call #each on it and let it iterate zero times if it's empty. David -- David A. Black (dblack@wobblini.net) Ruby Power and Light (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black