?c => "c" Ruby 1.8.6 irb(main):001:0> ?c => 99 what does "?" mean mean? +7 ruby Bohdan ...">

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
source share
3 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
source

In 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
source
 ruby-1.9.2-p0 > ?c == "c" => true 
-one
source

All Articles