gpt4 book ai didi

Ruby Hash.new 怪异

转载 作者:数据小太阳 更新时间:2023-10-29 08:14:58 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Strange ruby behavior when using Hash.new([])

这是一个简单的问题,因为我不知所措。

为什么会这样:

1.9.3-p194 :001 > h = Hash.new([])
=> {}
1.9.3-p194 :002 > h[:key1] << "Ruby"
=> ["Ruby"]
1.9.3-p194 :003 > h
=> {}
1.9.3-p194 :004 > h.keys
=> []
1.9.3-p194 :005 > h[:key1]
=> ["Ruby"]

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com