Q: return Array [1,'a',2,3] ASCII value


Hi everyone,

say if I have an array [1,‘a’,2,3] and I want to print out the ASCII
value of each element, how do it I do it?

I tried the following

[1,‘a’,2,3].each {|x| p ?x}

but apparently x isnt being treated as a variable with “?x” and it will
just return the ASCII value of the charater ‘x’.

Thx in advance


some one wrote:

[1,‘a’,2,3].each {|x| p ?x}

Okie, I found the solution…

[1,2,3,‘a’].each { |x| print x.to_s[0] }