← 返回命令列表

Linux command

irb 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Start interactive Ruby

irb

Start without prompt

irb --noprompt

Load file before starting

irb -r [library]

Evaluate expression

irb -e "[puts 'hello']"

Start with specific Ruby

irb --version

Simple prompt

irb --simple-prompt

说明

irb is the Interactive Ruby shell. It provides a REPL for evaluating Ruby expressions and exploring code. The shell supports tab completion, history, and multi-line input. It's the standard tool for Ruby experimentation.

参数

-r _LIBRARY_
Require library before starting.
-e _EXPR_
Evaluate expression.
--noprompt
Suppress prompt.
--simple-prompt
Use simple prompt.
--inf-ruby-mode
Emacs inf-ruby compatibility.
-I _PATH_
Add to load path.
--help
Display help information.

FAQ

What is the irb command used for?

irb is the Interactive Ruby shell. It provides a REPL for evaluating Ruby expressions and exploring code. The shell supports tab completion, history, and multi-line input. It's the standard tool for Ruby experimentation.

How do I run a basic irb example?

Run `irb` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -r _LIBRARY_ do in irb?

Require library before starting.