I've been tinkering with Sinatra (a framework on Ruby) lately, but was having trouble figuring out how to get information out of a huge nested hash. So I tweeted the below to my accidental mentor, Al Shaw, of Talking Points Memo:
@A_L Say @foo={"people"=>{ "nabe"=>"dumbo", "kids"=>[{"name"=>"ann", "age"=>"8"}, {"name"=>"joe", "age"=>"10"}]} How do I return "joe"?
He replied that my example was missing a } (yup) and that the answer was:
@foo = {"people"=>{"nabe"=>"dumbo", "kids"=>[{"name"=>"ann", "age"=>"8"}, {"name"=>"joe", "age"=>"10"}]}}
@foo["people"]["kids"][1]["name"] #=> "joe"
Now I get it!