From: Erwin Date: 2008-09-08T17:33:51+09:00 Subject: Re: any way to write it in one line ? On 6 sep, 21:16, William James wrote: > On Sep 6, 1:17 pm,Erwin wrote: > > >      works =  Array.new > > works = [] > > Instead of > > name = String.new > > one says > > name = "" > > >      session[:cart_works].each_pair {|key, value| works << key if > > value == user_id} > > > how to initialize the works array in the bloc ? > > > thanks for your lights > > >erwin > > h = Hash[ * %w(apple red lemon yellow bananna yellow orange orange) ] >     ==>{"bananna"=>"yellow", "apple"=>"red", "orange"=>"orange", > "lemon"=>"yello > w"} > a = h.keys.select{|k| 'yellow'==h[k] } >     ==>["bananna", "lemon"] thanks a lot...