I am playing around with nested hashes. Task:
Create three hashes called
person1
,person2
, andperson3
, with first and last names under the keys:first
and:last
. Then create a params hash so thatparams[:father]
isperson1
,params[:mother]
isperson2
, andparams[:child]
isperson3
. Verify that, for example,params[:father][:first]
has the right value.
My solution:
person1 = {first: "first_name1", last: "last_name1"}
person2 = {first: "first_name2", last: "last_name2"}
person3 = {first: "first_name3", last: "last_name3"}
params = { :father => ":person1", :mother => ":person2", :child => ":person3" }
then params[:father][:first]
gives
TypeError: no implicit conversion of symbol into Integer
Why? I don't understand why I get the TypeError.