Data Structures:Accessing Hash Values


This is lesson 9 for Data Structures in Ruby it keeps telling it looks like you didn't print anything in the console. Ive looked the other Hash value threads and cannot figure out what I'm doing wrong. Please help!

pets =
"Charlie" => "cat",
"Poptart" => "first",
"Cloe" => "oldest"

puts pets["Charlie"]


HI you have two ways for create a Hash


hash = {
  "stevie" => "cat",


pets =
pets["Stevie"] = "cat"

HOpe tha could help you...


yes it did I used curly brackets and did puts["name here"] for all three makes and it went.
Thank you!

if I use the curly bracket do I always have to use => and then if I use do I always have to use ["name here"] if use them both am I mixing code?



yes, and it won't work.


Thank you!

Makes sense now :slight_smile: