How to run Ruby code from terminal?

前端 未结 2 509
半阙折子戏
半阙折子戏 2021-01-30 03:53

I need to run a few lines of Ruby code from terminal, but I can\'t find the needed parameter for it.

Can you explain how to do this?

2条回答
  •  时光取名叫无心
    2021-01-30 04:15

    If Ruby is installed, then

    ruby yourfile.rb
    

    where yourfile.rb is the file containing the ruby code.

    Or

    irb
    

    to start the interactive Ruby environment, where you can type lines of code and see the results immediately.

提交回复
热议问题