From: Roberto Eduardo Decurnex Gorosito Date: 2007-12-19T00:06:40+09:00 Subject: Re: Convert a char into numbre ------=_Part_14095_32794716.1197990403173 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline You are right, thanks! On Dec 18, 2007 12:01 PM, Tim Hunter wrote: > Roberto Decurnex Gorosito wrote: > > I am have an String object like "12345678", and an Array object like > > [ 8,7,6,5,4,3,2,1]. > > The main idea is: > > > > myStr = '12345678' > > myArray = [8,7,6,5,4,3,2,1] > > total = 0 > > > > for i in 0..7 > > total+= myStr[ i ].to_i * myArray[ i ] > > end > > > > > > The awaited result is 120 but coz myStr[ i ] returns the ascii fixnum > > i can' t get it > > Try myStr[i,1] > > -- > RMagick: http://rmagick.rubyforge.org/ > > ------=_Part_14095_32794716.1197990403173--