Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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):003:1"
irb(main):004:1"
irb(main):005:1" exit
irb(main):006:1" escape
irb(main):007:1"

1 Answer