Ruby - Regular ExpressionsWhy does Ruby's named captures use symbols as keys in MatchData instead of strings?ASymbols are more memory-efficient and faster for repeated keys.BStrings cannot be used as keys in Ruby hashes.CSymbols automatically convert to integers internally.DUsing strings would cause syntax errors in regex.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand Ruby symbols vs stringsSymbols are immutable and reused, making them efficient as hash keys.Step 2: Eliminate incorrect optionsStrings can be hash keys; symbols do not convert to integers; strings do not cause regex syntax errors.Final Answer:Symbols are more memory-efficient and faster for repeated keys. -> Option AQuick Check:Symbols preferred for keys due to efficiency [OK]Quick Trick: Symbols save memory and speed up key lookups [OK]Common Mistakes:Thinking strings can't be hash keysBelieving symbols convert to numbersConfusing regex syntax with hash key types
Master "Regular Expressions" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Advanced Metaprogramming - Module_eval for dynamic behavior - Quiz 11easy Concurrent Programming - Thread creation and execution - Quiz 10hard Functional Patterns in Ruby - Pure functions concept - Quiz 2easy Gems and Bundler - Bundler for dependency resolution - Quiz 15hard Metaprogramming Fundamentals - Method_missing for catch-all - Quiz 15hard Ruby Ecosystem and Best Practices - Ruby version management (rbenv, rvm) - Quiz 13medium Ruby Ecosystem and Best Practices - Performance profiling basics - Quiz 9hard Testing with RSpec and Minitest - Mocking and stubbing - Quiz 14medium Testing with RSpec and Minitest - Test-driven development workflow - Quiz 5medium Testing with RSpec and Minitest - Mocking and stubbing - Quiz 5medium