From: Tim Uckun Date: 2006-05-11T19:15:05+09:00 Subject: Re: A more elegant way to do this? Thanks for all your replies. I knew there was a better way, I keptreading and thinking that I am still not thinking in ruby. On 5/11/06, Daniel Sheppard wrote:> > -----Original Message-----> > From: Tim Uckun [mailto:timuckun@gmail.com]> >> > Can anybody suggest a more elegant and rubyish way to do this?> >> > unless conf['hosts'][hostname]['groups'].nil?> > conf['hosts'][hostname]['groups'].each { |group|> > unless conf['crontables'][group].nil?> > conf['crontables'][group].each { | tab_item|> > tab_entries << tab_item> > }> > end #Unless> > }> > end #unless>> use (value||[]), ie:>> (conf['hosts'][hostname]['groups']||[]).each { |group|> (conf['crontables'][group]||[]).each { | tab_item|> tab_entries << tab_item> }> }>>>