From: Mikael Brockman Date: 2004-08-28T03:56:31+09:00 Subject: Re: Question about ? operator for ASCII Edgardo Hames writes: > On Sat, 28 Aug 2004 01:59:05 +0900, Barry Sperling wrote: > > Hello, > > I am a nuby and I couldn't find how to get the ASCII value of a > > character in a variable. I looked in the Pragmatic Programmer and did this: > > > > s = "ABC DE." > > s.scan( /./ ) do |a| > > puts ?a > > end > > > > but only got the ASCII value of the small letter 'a' ( 97 ). What do I > > need to do? > > I know this one!!!!! I can't believe it ;) You need to call the #chr > method for integers. > > s = "ABC DE." > s.scan( /./ ) do |a| > puts a.chr > end > > Regards, > Ed Hate to rain on your parade, but #chr is actually a method on Fixnum, and converts an integer to a string. (Barry wanted the integer value, but had only the string value.) mikael