Hash


#1

I'm struggling with what seems to be really simple
how do you do this?
Use Hash.new to create a new hash called pets. Hash must be capitalized, or Ruby won't know what you're talking about!

Please help


#2

Hi can you post your code?


#3

I don't know the code - that's the problem :slight_smile:
the previous lesson just gave me following example
my_hash = { "name" => "Eric",
"age" => 26,
"hungry?" => true
}

puts my_hash["name"]
puts my_hash["age"]
puts my_hash["hungry?"]

in this lesson, I'm just supposed to create a new hash called pets. Hash
there's just following example above the instruction:
my_hash = Hash.new

this apparently creates a new hash. When I try to apply the same logic for creating pets.Hash..it's not working

hope I'm making sense


#4

so in the lesson you have that example

my_hash = Hash.new

which is an empty Hash name my_hash so if you want an empty Hash name pets you should do it like that

pets = Hash.new

#5

thanks a lot - I've just realized I've misread the instructions
thanks!!!!