Using "ruby" with no arguments freezes the terminal

I am new to Ruby and have Ruby 1.9.3 installed on an Ubuntu 12.04 machine.

Whenever I run the ruby command in a terminal with no arguments, it just freezes and does nothing. It does the same on my installation of Windows XP.

Is this the expected behavior? Based on the Python / Java background, I was expecting some kind of output.

+6
source share
2 answers

Expected. When you run only ruby , it sits there, waiting for the program from STDIN, followed by the end-of-file character, after which it launches the program.

If you want to work in interactive mode, for example, when starting python , you need Ruby irb .

+13
source
  • to test your ideas in the console

    type irb

  • to run the program on the console

    type ruby program_I_want_to_run.rb

-2
source

All Articles