gpt4 book ai didi

ruby-on-rails - Ruby:比较两个哈希值

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

<分区>

我有两个哈希-

hash1 = {a: "2", b: "34", c: "53", d: "23", e: "2"}
hash2 = {a: "5", c: "8", d: "3", e: "2", f: "76"}

我需要比较哈希并获取下一个-

hash1_1 = {a: "2", c: "53", d: "23", e: "2"}
hash2_1 = {a: "5", c: "8", d: "3", e: "2"}

也就是我需要比较两个散列,只留下那些键值相等且同时存在两个散列的值。

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