In past Ruby versions, the question mark operator returned the ASCII value of a character. For example, ?g will return the integer 103, the ASCII code for the character lower-case g. This, however, turned out to be less than useful.
In Ruby 1.9, this has changed. The question mark operator now returns a single-character string of that character. For example, ?g will return "g".
To get the old behavior, to get the ASCII value of a string, use the ord method. The ord method returns the ASCII value of the first character of a string.
#!/usr/bin/env ruby # In Ruby 1.9, this returns a single # character string puts ?g # To get the ASCII value, use the ord method "g".ord