-1

I'm in the terminal and I'm running IRB. I'm trying to get the ASCII value of x. I know the value is 120. That's correct right? When I type the following into my terminal this is the response I get:

puts ?x
(output) x

Why isn't it coming up 120?

jvnill
  • 29,479
  • 4
  • 83
  • 86

1 Answers1

1

String#ord could be used to get the integer representation of a one-character string:

'x'.ord
# => 120

P.S: use 'x' or "x" instead of ?x.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294