From: Rick DeNatale Date: 2008-07-15T05:55:36+09:00 Subject: Re: how to loop through two arrays in parallel ------=_Part_59271_13907523.1216069210226 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Jul 14, 2008 at 4:03 PM, Mitchell Gould wrote: > I have two arrays from a form. > > > params[:products] and params[:quantity] > > which are products[] and quantity[] > > I would like to extract the data from each item to get their name and > quantity. > > Is there a way in Ruby to do this? > > > for product in products[] and quantity in quantity[]? > -- > Posted via http://www.ruby-forum.com/. > > %w(a b c).zip([2, 4, 3]).map {|product, quantity| "#{quantity} #{product} on hand"} => ["2 a on hand", "4 b on hand", "3 c on hand"] -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ ------=_Part_59271_13907523.1216069210226--