Interactive Ruby Shell

Interactive Ruby Shell (IRB or irb) is a REPL for programming in the object-oriented scripting language Ruby. The abbreviation irb is a portmanteau of the word "interactive" and the filename extension for Ruby files, ".rb".

Interactive Ruby Shell
The screenshot session as same as the article example
Developer(s)Keiju Ishitsuka
Stable release
0.9.6 / June 30, 2009 (2009-06-30)
Written inRuby
Operating systemCross-platform
PlatformRuby interpreter
TypeRuby shell
LicenseRuby License
BSD License

The program is launched from a command line and allows the execution of Ruby commands with immediate response, experimenting in real-time. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. It was developed by Keiju Ishitsuka.

Syntax and use


irb [ options ] [ programfile ] [ argument... ]


irb(main):001:0> n = 5
=> 5
irb(main):002:0> def fact(n)
irb(main):003:1>   if n <= 1
irb(main):004:2>     1
irb(main):005:2>   else
irb(main):006:2*     n * fact(n - 1)
irb(main):007:2>   end
irb(main):008:1> end
=> :fact
irb(main):009:0> fact(n)
=> 120

irb(main):001:0> class Cat
irb(main):002:1>   def meow
irb(main):003:2>     puts 'The cat meows.'
irb(main):004:2>   end
irb(main):005:1> end
=> :meow

The cat meows.

See also

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.