4

I started to learn Ruby using IRB and wrote the wrong code below:

irb(main):001:0>"amefurashi".delete(aiueo")

I noticed it was missing a double-quote mark, and the prompt changed to:

irb(main):002:1"

I wrote the correct code:

irb(main):001:1"amefurashi".delete("aiueo")

but why won't it work?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Kotaro Ezawa
  • 1,509
  • 3
  • 13
  • 11
  • `ruby-1.9.2-p290 :001 > "amefurashi".delete("aiueo") => "mfrsh"` - what are you expecting to happen? – wkl Sep 24 '11 at 05:51

1 Answers1

10

The IRB lines that prompt you with > are for new statements.

When the prompt says " instead, that means you are inside a string, and IRB is expecting you to finish entering your text and close your string with another quotation mark.

It looks like what you are doing is trying to enter your statement again, before you get a new (>) prompt.

If you are stuck in the middle of an incorrect statement and want to start over, press Ctrl-C, then Enter and you will get a clean > prompt.

Andrew Vit
  • 18,961
  • 6
  • 77
  • 84