Bird
0
0

What will this Ruby code output?

medium📝 Predict Output Q4 of 15
Ruby - Hashes
What will this Ruby code output?
config = { language: 'Ruby', version: 3.0 }
puts config[:language]
ARuby
Blanguage
Cversion
Dnil
Step-by-Step Solution
Solution:
  1. Step 1: Access hash value by key

    config[:language] retrieves the value associated with the :language key.
  2. Step 2: Identify stored value

    The value for :language is 'Ruby'.
  3. Final Answer:

    Ruby -> Option A
  4. Quick Check:

    Access hash values with keys using [:key] [OK]
Quick Trick: Use [:key] to get hash values [OK]
Common Mistakes:
  • Using string keys instead of symbol keys
  • Expecting key name instead of value
  • Confusing key with value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes