Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape/exit in IRB after entering code that requires more input/does not execute right away [closed]

Tags:

ruby

irb

A particular line of code results in no output, and IRB exits out of the >> prompt. I am not looking to exit IRB, but just to exit to a state preceding the line of code that caused the >> prompt to go away.

>> stop_words = %w {the a and if}
>> stop_words.each{|x| stop_words << x.capitalize}
quit
quit
quit
  1. Once I enter this situation, I cannot even exit the IRB shell, as the 'quit' command does not execute any changes.
  2. I would like to exit the state and still have my preceding variable definitions intact, so that in the code example, I could call on stop_words to experiment with it. Any elucidation/insight into what's going on here is appreciated.
like image 322
Bodhidarma Avatar asked Oct 22 '22 18:10

Bodhidarma


1 Answers

Your code infinitely loops, so you don’t get a new prompt as it is still processing your previous command.

You can hit CtrlC to abort the currently running command immediately.

like image 191
Andrew Marshall Avatar answered Nov 01 '22 09:11

Andrew Marshall