1
之間移動屬性我有如何散列
hash1 = {:sym1 => "aaa", :sym2 => "bbb"}
hash2 = {:sym20 => "ccc", :sym21 => "ddd"}
如何使
hash1 = {:sym1 => "aaa"}
hash2 = {:sym2 => "bbb", :sym20 => "ccc", :sym21 => "ddd"}
之間移動屬性我有如何散列
hash1 = {:sym1 => "aaa", :sym2 => "bbb"}
hash2 = {:sym20 => "ccc", :sym21 => "ddd"}
如何使
hash1 = {:sym1 => "aaa"}
hash2 = {:sym2 => "bbb", :sym20 => "ccc", :sym21 => "ddd"}
hash2[:sym2] = hash1.delete(:sym2)
或者使用hash2.merge! sym2:hash1.delete(:sym2) –