0
爲什麼從密鑰中刪除密鑰,將密鑰從哈希中刪除?爲什麼從密鑰中刪除密鑰,將密鑰從另一個密碼中刪除?
msg = { key1: "XXX",key2: 'xxx' }
send_msg(msg)
send_msg(msg)
def send_message(msg)
p msg
msg.delete(:key1)
end
輸出:
=> { key1: "XXX",key2: 'xxx' }
=> { key2: 'xxx' }
另外:
irb(main):023:0> a = { key1: "XXX",key2: 'xxx' }
=> {:key1=>"XXX", :key2=>"xxx"}
irb(main):024:0> b=a
=> {:key1=>"XXX", :key2=>"xxx"}
irb(main):025:0> a.delete(:key1)
=> "XXX"
irb(main):026:0> a
=> {:key2=>"xxx"}
irb(main):027:0> b
=> {:key2=>"xxx"}
它是一個參考?
是的,它是一個參考 – emaillenin