From: "Jesús Gabriel y Galán" Date: 2008-09-07T03:23:49+09:00 Subject: Re: any way to write it in one line ? On Sat, Sep 6, 2008 at 8:14 PM, Erwin wrote: > works = Array.new > session[:cart_works].each_pair {|key, value| works << key if > value == user_id} > > how to initialize the works array in the bloc ? Maybe: works = session[:cart_works].inject([]) {|w, (k,v)| (v== user_id)? w + [k]: w} Jesus.