?!, IRC #ruby, >> and eval.in

Want to know what the “?!” bit in this line means in Ruby?

          if command[0] == ?!

To work it out, in IRC #ruby, use:

>> ?!

which executes it via eval.in. E.g.


In a nutshell, if you don’t want to go through all that, here’s what ?! does:

In newer Ruby’s:

?! => “!”

In older Ruby’s, ? used to return the ASCII code. So:

?! would return the ASCII code for ! (i.e. 33). 

Nowadays you’d do it using: 


which returns 33.

? is a literal in Ruby.

Leave a Reply

Your email address will not be published. Required fields are marked *