From: Peter Hickman Date: 2007-07-19T00:01:03+09:00 Subject: Re: type conversion Shandy Nantz wrote: > Sorry about not giving code. I did finally get it to work, but here is > what I had to do: > > card_num = "123456789" > c = 0 > > char = card_num[i..i].to_i > > before I had: > > char = card_num[i].to_i > > All I wanted to do was to pick out a single character (a digit) from > that string and perform some calculations on it. But by just saying [i] > I got a 57 value when I wanted the 9 value. When I said [i..i] I got the > 9 value. Thanks for all your help, > > ~S > > Card_num[i] is returning the character value at position i. card_num[i].chr will return the character at position i card_num[i].chr.to_i will return the integer value of the character card_num[i].type => Fixnum card_num[i..i].type => String and is why card_num[i..i].to_i worked