From: Phrogz Date: 2007-01-21T03:06:58+09:00 Subject: Re: Proper way to either create or append to an array? Adam Block wrote: > Let's say I want to either create a new named array or append to that > array if it already exists. Is there a more elegant way of doing the > following? > > >> @foo[:bar].nil? ? foo[:bar] = ["snafu"] : foo[:bar] << "snafu" Dunno if you'd call it elegant, but I frequently write: ( @foo[:bar] ||= [] ) << "snafu"