Ruby - Hashes
Which of the following is the correct syntax to create a Ruby hash with a default value of an empty array for missing keys?
Hash.new allows dynamic default values. To assign a new array to each missing key, the block must assign it to the hash.hash and key parameters and assigns [] to hash[key]. This ensures each missing key gets its own array.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions