Chris Pine's How to Program mentions that the following:
?T
should return 84
. When I run it, it returns "T"
. My suspicion is that there is a version difference. My guess is that ?
is an Array
or String
method, but I cannot find documentation. What does ?T
do?
In this context,
?
with a character is a literal single character string. Therefore?T
is the String "T" andputs ?T
is the same asputs "T"
You can throw it into IRB to check it out:Related Existing SO Questions and Answers:
Edit to add: Per a comment on the answer linked above this might have been a change in ruby 1.9 to return a single character String instead of the ASCII character value. (which the ASCII value of T is 84 )