5

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.
Bodhidarma
  • 519
  • 1
  • 7
  • 25
  • I had to add quotation marks to the >> so that stackoverflow could display them. It's not a pretty edit job but it gives a rough idea of what I'm trying to communicate. – Bodhidarma Jan 30 '13 at 04:43
  • 2
    No, you don’t have to add `"`s. Instead [properly format code blocks](http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks). – Andrew Marshall Jan 30 '13 at 04:51
  • @sawa That last quote may have not been added for formatting purposes, as the OP only stated they had to quote the `>>`s. – Andrew Marshall Jan 30 '13 at 04:55
  • @AndrewMarshall But it is not balanced. You might have better idea how it is supposed to be. Please edit if you have an idea. I am not sure. – sawa Jan 30 '13 at 04:58
  • @sawa So? It could very well be the cause of the OP’s problem. – Andrew Marshall Jan 30 '13 at 04:59
  • @AndrewMarshall Maybe you are right. I added the quotation. – sawa Jan 30 '13 at 05:00
  • 1
    I don't think the quotation was intended. The problem occurs without it. – Geoff Jan 30 '13 at 05:02
  • By the way, I assume you realize it hangs because it's an infinite loop right? – Geoff Jan 30 '13 at 05:09
  • Geoff is correct in saying the problem occurs without it and in his inference that the quotation was not intended. I accidentally added it while trying to format the question as quickly as possible. Also, Thank you Andrew Marshall for the link to properly formatting code blocks. – Bodhidarma Jan 30 '13 at 05:10
  • @Geoff. After printing the contents of stop_words I realized that was the case, but was not familiar enough with the logic and how the methods work to realize it by assessing the code alone. I'm working on it. – Bodhidarma Jan 30 '13 at 05:23

1 Answers1

3

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.

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214