What "?" in ruby
Ruby 1.9
irb(main):001:0> ?c => "c" Ruby 1.8.6
irb(main):001:0> ?c => 99 what does "?" mean mean?
+7
Bohdan
source share3 answers
It stands for "symbol." In Ruby 1.8, this was represented by an ascii character code. In Ruby 1.9, this is a single-character String .
+9
Lindydancer
source shareIn 1.8 they give you the value of an ASCII character, in 1.9 they are character literals:
>> RUBY_VERSION #=> "1.8.7" >> ?a #=> 97 >> RUBY_VERSION #=> "1.9.2" >> ?a #=> "a" >> *[?a..?c] #=> ["a", "b", "c"] +7
Michael kohl
source share