Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't IRB work after I mistyped a string?

Tags:

ruby

irb

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?

like image 382
Kotaro Ezawa Avatar asked Dec 28 '22 13:12

Kotaro Ezawa


1 Answers

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.

like image 126
Andrew Vit Avatar answered Jan 20 '23 19:01

Andrew Vit