From: Adam Shelly Date: 2008-08-15T03:31:25+09:00 Subject: Re: nested loop On 8/14/08, Erwin wrote: > residence_rentals_ids = [] > user.franchise.residences.each { |residence| residence.rentals.map { | > rental| residence_rentals_ids << rental[:id] }.compact } > > but is there a way to avoid the residence_rentals_ids = [] line, > including the array initialization into a block ? residence_rentals_ids = user.franchise.residences.map{ |residence| residence.rentals.map { |rental| rental[:id] }.compact }.flatten