amindfv amindfv - 9 months ago 59
Ruby Question

Create or append to array in Ruby

foo ||= []
foo << :element

Feels a little clunky. Is there a more idiomatic way?

Answer Source
(foo ||= []) << :element

But meh. Is it really so onerous to keep it readable?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download