How `? N` is different from `` n``?

Chris Pine As the program indicates the following:

?T

must return 84. When I launched it, it returns "T". My suspicion is that there is a difference in version. I assume that ?this is a method Arrayor String, but I can not find the documentation. What does it do ?T?

+4
source share
1 answer

In this context, ?with a character is a literal single character string. Therefore, it ?Tis the string "T", and puts ?Tmatches with puts "T". You can drop it on the IRB to check it out:

1.9.3p429 :002 > ?T
 => "T" 
1.9.3p429 :001 > ?T.class
 => String 
1.9.3p429 :003 > puts ?T
T
 => nil

Related Existing SO Questions and Answers:

: , , , ruby ​​1.9, String ASCII. ( ASCII T 84)

1.9.3p429 :006 > ?T.ord
 => 84 
+8

All Articles