5

When I paste this code in irb prompt I get listing of current directory after line if true.

def some_method()

  if true
        raise StandardError
    end

end

Example of output:

irb(main):151:0> def some_method()
irb(main):152:1> 
irb(main):153:1*   if true
irb(main):154:2> 
.Skype/                          .m2/                             Desktop/
...

I use irb 0.9.5(05/04/13) and ruby 1.8.7 (2011-12-28 patchlevel 357).

Is this a bug, or something else?

1
  • 1
    this is very weird. does the session continue to work afterwards?
    – Niklas B.
    Mar 4, 2012 at 22:11

2 Answers 2

4

The following line will have tab characters in it:

        raise StandardError

irb uses readline which means that the tab key is used for tab completion. Double tab will show you all the available options.

To see this in action, just launch irb and hit the tab key twice.

See https://superuser.com/questions/37148/how-to-disable-double-tab-to-show-available-commands-in-linux-console for guidance on how to disable it.

1
  • 2
    This results in one of the more interesting and esoteric pros of using soft tabs. Mar 4, 2012 at 23:43
1

Because of the reason Don Cruickshanks mentioned, you should set the option to convert tabs to spaces in your text editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.