Question

If an array is improperly defined, it seems to render irb unusable. Or does it?

See example below:

irb(main):003:0> set = ['a]
irb(main):004:1'
irb(main):005:1' g
irb(main):006:1' q
irb(main):007:1' '
irb(main):008:1> set
irb(main):009:1> puts 'hello'
irb(main):010:1>
irb(main):011:1*
irb(main):012:1* '
irb(main):013:1' '
irb(main):014:1> '
irb(main):015:1' '
irb(main):016:1> "
irb(main):017:1" "
irb(main):018:1> puts "hello"
irb(main):019:1> ^C
irb(main):019:0>
irb(main):020:0*
irb(main):021:0* ^C
irb(main):021:0> exit
Was it helpful?

Solution

When you didn't close your single-quoted string, irb started treating everything following (including the close-array ]) as part of that string.

To get back to a prompt that works, you either need to

  1. Close the string and the array - that is, match the ' and then the ]; or
  2. Press Ctrl-C, which drops you out of your context

See that the last digit in the prompt changes to 1 after your malformed string, and back to 0 after Ctrl-C? That's the nesting depth. If it's at 0, you're back in the main context of itb.

OTHER TIPS

This happens because you forgot the first quote in the beginning. It will add that quote to the next input. Press ctrl-C and try again. That should fix it.

If that doesn't help, try ctrl-D this will send an EOF to irb. See: http://en.wikipedia.org/wiki/End-of-file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top