我的哈希像
hash = {"19206"=>{"ordet_id"=>"4", "discount"=>"22"}, "19207"=>{"ordet_id"=>"2", "discount"=>"11"}}
可能有很多索引器。获得discount
值的最佳方法是什么?
像这样吗?
hash.each {|index, value| value[:discount]}
还是有更好的方法进行处理?
Ruby 1.8.7
轨2.3.4
答案 0 :(得分:2)
嵌套哈希中的键是字符串,因此无法使用符号键获取值。我会改成这样
hash.map { |_k, v| v['discount'] }
答案 1 :(得分:0)
只需另一个版本即可获得预期的结果。
GameObject g = Instantiate(prefabName, position, rotation);
GameObject g = Instantiate(prefabName, position, rotation, parentName);
GameObject g = Instantiate(prefabName, parentName, instantiateInWorldSpace);