MAP_PERSONAL_DATA_WITH_TAG = {"Flat/Unit No." => "FLD_ADD_1Line1",
"Building No./Name" => "FLD_ADD_2Line2",
"Street" => "FLD_ADD_3Line3",
"Postcode" => "FLD_ADD_4Postcode",
"City/Town" => "FLD_ADD_5City",
"Region" => "FLD_ADD_6State",
"Suburb" => "FLD_ADD_Town"
}
data_hash = {"Street" => "s", "Suburb" => "sb", "abc" => "hdkhd"}
data_hash.each do |key, value|
case key
when <if key equal to the key of MAP_PERSONAL_DATA_WITH_TAG i.e MAP_PERSONAL_DATA_WITH_TAG.has_key?(key)>
puts 'something'
when "Mobile"
puts "something mobile"
else
puts 'something else'
end
end
不用編寫像紅寶石情況下,當一個散列聲明
當「平/無單位」,「建設No./Name","Street","Postcode","City/Town 「,」地區「,」郊區「
有沒有更好的方法來寫這個?
我需要對data_hash – asinha