Ruby - Hashes
What is the output of the following Ruby code?
person = { name: "Carol", "age" => 28 }
puts person[:name]
puts person["age"]person = { name: "Carol", "age" => 28 }
puts person[:name]
puts person["age"]:name and a string key "age". Accessing with matching key types returns values.person[:name] returns "Carol". person["age"] returns 28. Both print on separate lines.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions