Ruby Ruby Collections Ruby Arrays Accessing Items in Arrays

Edely Gomes
Edely Gomes
4,485 Points

How to cancel a statement in irb?

Sometimes when I write a statement that is missing a close quotation mark in irb, I get stucked because the irb doesn't throw an error or abort the statement.

It just keeps running and i can't cancel it and start again. So I have to close the console and initialize all from start.

What should I do to cancel the statement? I tried to write exit or escape, but nothing works.

Here is a example:

irb(main):001:0> grocery_list = ["milk", "bread", "eggs"]
=> ["milk", "bread", "eggs"]
irb(main):002:0> grocery_list.include?("water)
irb(main):005:1" exit
irb(main):006:1" escape

1 Answer