使用沒有參數的'ruby'凍結終端

[英]Using 'ruby' with no arguments freezes terminal


I'm a Ruby newbie and have Ruby 1.9.3 installed on an Ubuntu 12.04 machine.

我是一個Ruby新手,並在Ubuntu 12.04機器上安裝了Ruby 1.9.3。

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

每當我在沒有參數的終端中運行ruby命令時,它就會掛起並且什么也不做。它在我的Windows XP安裝上做同樣的事情。

Is this the expected behavior? Coming from a Python/Java background I expected some kind of output.

這是預期的行為嗎?來自Python / Java背景我期待某種輸出。

2 个解决方案

#1


13  

This is expected. When you run just ruby, it sits there, waiting for a program from STDIN, followed by an end-of-file character, after which it executes the program.

這是預料之中的。當你只運行ruby時,它就坐在那里,等待來自STDIN的程序,然后是文件結束字符,然后執行程序。

If you want interactive, like when you run python, you want Ruby's irb.

如果你想要交互式,就像你運行python一樣,你需要Ruby的irb。

#2


-2  

  • to check your ideas in console

    在控制台中檢查你的想法

    type irb

  • to run a program in console

    在控制台中運行程序

    type ruby program_I_want_to_run.rb

    輸入ruby program_I_want_to_run.rb


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2013/02/24/729b8ca334ff771461c6a2105ed6ca14.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com