如何从终端运行Ruby代码? [英] How to run Ruby code from terminal?

查看:64
本文介绍了如何从终端运行Ruby代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从终端运行几行Ruby代码,但找不到所需的参数.

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

你能解释怎么做吗?

推荐答案

如果已安装Ruby,则

If Ruby is installed, then

ruby yourfile.rb

其中 yourfile.rb 是包含红宝石代码的文件.

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

irb

启动交互式Ruby环境,您可以在其中键入代码行并立即查看结果.

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

这篇关于如何从终端运行Ruby代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆