use (value||), ie:
(conf['hosts'][hostname]['groups']||).each { |group|
(conf['crontables'][group]||).each { | tab_item|
tab_entries << tab_item
}
}
···
-----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
Thanks for all your replies. I knew there was a better way, I kept
reading and thinking that I am still not thinking in ruby.
···
On 5/11/06, Daniel Sheppard <daniels@pronto.com.au> 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
}
}