harvey
harvey

Reputation: 299

What do symbols mean in IRB?

I couldn't find anything about this in ruby-doc.

I can have such things in IRB :

2.2.0 :012">

or

2.2.0 :012?>

I don't know what those symbols mean. Do you know ? Is it to warn that I missed one ? or one " ?

Upvotes: 1

Views: 192

Answers (1)

Waynn Lue
Waynn Lue

Reputation: 11385

If you're using rvm, they have a custom irb.rc file that define a few different behaviors for irb. In particular, there's this section:

@prompt = {
  :PROMPT_I => "#{rvm_ruby_string} :%03n > ",  # default prompt
  :PROMPT_S => "#{rvm_ruby_string} :%03n%l> ", # known continuation
  :PROMPT_C => "#{rvm_ruby_string} :%03n > ",
  :PROMPT_N => "#{rvm_ruby_string} :%03n?> ", # unknown continuation
  :RETURN => " => %s \n",
  :AUTO_INDENT => true
}

So the ? means that it's an unknown continuation, and it isn't sure how to prompt you to complete your current command. The " shows when you have an unmatched quote, like this:

irb(main):024:0> "foo
irb(main):025:0" "
=> "foo\n"
irb(main):026:0> 

Upvotes: 3

Related Questions