user3334690
user3334690

Reputation: 899

What is the ? in ?char

I do not understand the ? in ?x.succ. What is it?

(This question was prompted by this answer on code golf.)

Upvotes: 2

Views: 80

Answers (1)

tadman
tadman

Reputation: 211610

That just means "character", as in ?x is "x character". This was a bigger deal in versions of Ruby prior to 1.9. Now it's mostly an anachronism.

Ruby 1.9+:

?x
# => "x"

Ruby 1.8.7 and prior:

?x
# => 120

This was similar to how 'x' in C is a single character where "x" is a character string.

Upvotes: 4

Related Questions