Interactive Ruby
Interactive Ruby (IRB、irb) は、Rubyを対話的に実行 (REPL) するためのシェルである。
この項目「Interactive Ruby」は翻訳されたばかりのものです。不自然あるいは曖昧な表現などが含まれる可能性があり、このままでは読みづらいかもしれません。(原文:英語版 "Interactive Ruby Shell" 2020年5月11日 (月) 17:57 (UTC)) 修正、加筆に協力し、現在の表現をより自然な表現にして下さる方を求めています。ノートページや履歴も参照してください。(2020年7月) |
| 開発元 | 石塚圭樹 |
|---|---|
| 最新版 |
1.15.1
/ 2025年1月22日[1] |
| リポジトリ | |
| プログラミング 言語 | Ruby |
| 対応OS | クロスプラットフォーム |
| 種別 | シェル |
| ライセンス | 2条項BSDライセンス |
| 公式サイト |
github |
Interactive Ruby (IRB、irb) は、Rubyを対話的に実行 (REPL) するためのシェルである。
irbコマンドを実行することでコマンドプロンプトが表示され、Rubyの式を入力することでそれが実行され、結果が表示される。
Readlineがインストールされている場合、コマンドライン編集や履歴などの機能を利用できる。
Ruby 2.7に添付されているirbでは、Readlineに代わってRelineが採用された[2]。
irbは石塚圭樹によって開発された。
構文と実行例
構文:
irb [options] file_name opts
実行例:
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
irb(main):006:0> Cat.new.meow
The cat meows.
脚注
- ^ “All versions of irb”. RubyGems.org. 2025年2月9日閲覧。
- ^ naruse (2019年12月25日). “Ruby 2.7.0 リリース”. ruby-lang.org. 2020年7月6日閲覧。
関連項目
外部リンク
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.