From: Joey Date: 2006-07-23T19:32:40+09:00 Subject: Re: Dividing inside iterations? ------=_Part_45054_13850204.1153650757564 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Yes, but in assignement the variable goes on the left. h = [40,20,50,200] h.each do |num,total| total = num / 24 print "#{total} \n" end j`ey http://www.eachmapinject.com On 7/23/06, Dominic Son wrote: > > Hi > > Learning Ruby. > > Is it possible to divide values while inside an iteration? > > for example i'd like to do something like this: > > h = [40,20,50,200] > h.each do |num,total| num / 24 = total > print "#{total} \n" end > > as you'd expect, there is an error because of that '/' and '=' sign in > this iterator. > > so since this isn't possible what would be the best way to do what i'm > trying to do? or perhaps my syntax is wrong > > thank you very much. > > Dominic > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_45054_13850204.1153650757564--