newbie:如何从{:country_code =>“FR”获取单个值,:country_code1 =>“FRE”,:country_name =>“France”,:region =>“11”,:city => “巴黎”}

时间:2012-03-07 18:41:30

标签: ruby-on-rails ruby-on-rails-3 hash

如何从{:country_code =>“FR”获取单个值,:country_code1 =>“FRE”,:country_name =>“France”,:region =>“11”,:city =&gt ;“巴黎”}?

我想得到的价值:城市 什么都行不通我尝试:(

1 个答案:

答案 0 :(得分:3)

这是hash

hash = {:country_code=>"FR", :country_code1=>"FRE", :country_name=>"France", :region=>"11", :city=>"Paris"}

puts hash[:city]
>> "Paris"