← Back to Ruby Course | Chapter 1: Setup & Basics | Lesson 3 of 7

IRB (इंटरैक्टिव Ruby)

IRB Ruby के लिए एक chat window है जहाँ आप एक line type करते हैं और तुरंत एक answer पाते हैं। यह ideas try करने के लिए एक scratch pad जैसा है।

In this page:

  1. IRB (Interactive Ruby)
Syntax
ruby
irb
irb(main):001> expression

IRB (Interactive Ruby)

IRB Ruby का interactive console है, एक terminal में irb type करके शुरू होता है, जहाँ आप expressions type कर सकते हैं और तुरंत results देख सकते हैं। बिना एक file बनाए Ruby के छोटे snippets experiment करने का यह सबसे fast तरीका है।

हर expression का result automatically print होता है, एक calculator जैसा।

Note: एक IRB session छोड़ने के लिए exit type करें या Ctrl+D दबाएँ।

उदाहरण: IRB (Interactive Ruby)

markup
# Simulating what you'd see interacting with irb:
puts "2 + 2 = #{2 + 2}"
puts "In irb, typing '2 + 2' alone would print '=> 4' automatically"
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. IRB में एक multi-line method type करना और जल्दी Enter दबाना, definition बहुत जल्दी खत्म करते हुए।
  2. यह मान लेना कि IRB छोड़ने के बाद variables रहते हैं, जब exit पर session state खो जाता है।
  3. यह उम्मीद करना कि => 4 printed output है, जब यह expression की return value है, जबकि puts output की अपनी line होती है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.