Morton Goldberg
7/18/2007 3:07:00 PM
On Jul 18, 2007, at 10:51 AM, 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,
It's a bit late, I guess, but did you consider something like:
"123456789"[-1] - ?0 # => 9
Regards, Morton