From: Mikael Brockman Date: 2004-08-28T02:16:35+09:00 Subject: Re: Question about ? operator for ASCII Barry Sperling writes: > 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? > Thanks, > Barry | irb(main):005:0> s = "ABC DE." | => "ABC DE." | irb(main):006:0> s.scan(/./) do |a| | irb(main):007:1* puts a[0] | irb(main):008:1> end | 65 | 66 | 67 | 32 | 68 | 69 | 46 | => "ABC DE." | irb(main):009:0> s.each_byte do |a| | irb(main):010:1* puts a | irb(main):011:1> end | 65 | 66 | 67 | 32 | 68 | 69 | 46 | => "ABC DE." mikael