官术网_书友最值得收藏!

  • Mastering Chef
  • Mayank Joshi
  • 187字
  • 2021-07-16 14:02:24

IRB

IRB is an acronym for "interactive Ruby". It's a tool that provided alongside Ruby interpreter, which allows for the interactive execution of Ruby expressions. These expressions are delivered to IRB using standard input.

Let's quickly see IRB in action:

 ~ irb
2.1-head :001 >

When we enter the irb command, it throws a shell at us. The format of the shell prompt is as follows:

$RUBY_VERSION :$LINE_NUMBER >

You can customize this prompt to your liking. However, for now, just remember that whatever expression you enter at the prompt is interpreted as a Ruby expression and is evaluated right away.

Consider the following as an example:

irb
2.1-head :001 > 2+3
 => 5

As you can see, we entered an arithmetic expression to compute the sum of two numbers, 2 and 3, and in return IRB returned us the output of computation.

To exit out of IRB, just issue the quit or exit command at the prompt.

To learn more about IRB and how to customize it to your liking, read the IRB documentation at http://ruby-doc.org/stdlib-2.1.5/libdoc/irb/rdoc/IRB.html. Replace 2.1.5 with the Ruby version installed on your machine.

主站蜘蛛池模板: 浙江省| 永靖县| 开平市| 通渭县| 铅山县| 长宁县| 巴彦淖尔市| 腾冲县| 临安市| 阿鲁科尔沁旗| 涟源市| 碌曲县| 禄劝| 晋城| 额尔古纳市| 大石桥市| 安徽省| 曲靖市| 嘉黎县| 石首市| 海阳市| 武夷山市| 方山县| 法库县| 乾安县| 沿河| 达州市| 连云港市| 台南市| 东兰县| 金华市| 元阳县| 讷河市| 普兰县| 青阳县| 黄梅县| 龙井市| 嘉黎县| 沙河市| 唐河县| 竹北市|