Bird
0
0

Why does IRB use symbols like :SIMPLE instead of strings for prompt modes in ~/.irbrc?

hard📝 Conceptual Q10 of 15
Ruby - Ecosystem and Best Practices
Why does IRB use symbols like :SIMPLE instead of strings for prompt modes in ~/.irbrc?
AStrings cause syntax errors in IRB config
BSymbols are immutable and faster for repeated keys
CSymbols automatically load prompt libraries
DStrings cannot be used as keys in Ruby hashes
Step-by-Step Solution
Solution:
  1. Step 1: Understand symbols vs strings in Ruby

    Symbols are immutable and unique, making them efficient for keys.
  2. Step 2: Explain why IRB uses symbols for prompt modes

    Using symbols avoids repeated string objects and speeds up lookup.
  3. Final Answer:

    Symbols are immutable and faster for repeated keys -> Option B
  4. Quick Check:

    Symbols optimize performance and memory in configs [OK]
Quick Trick: Symbols are efficient keys, preferred over strings [OK]
Common Mistakes:
  • Believing strings can't be hash keys
  • Thinking symbols load libraries
  • Assuming strings cause syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes