我试图比较两个哈希数组,并删除旧记录。 stale_records
是来自old_records
的{{1}}中不存在的记录new_records
。数组中的项目可以重复。
old_records = [{a: 1}, {b: 2}]
new_records = [{a: 1}]
stale_records = #=> [{:b=>2}]
old_records = [{a: 1}, {a: 1}]
new_records = [{a: 1}]
stale_records #=> [{a: 1}]
我想知道几百万条记录是否有效。
我试过了:
old_records = [{a: 1}, {b: 2}]
new_records = [{a: 1}]
stale_records = old_records - new_records #=> [{:b=>2}]
old_records = [{a: 1}, {a: 1}]
new_records = [{a: 1}]
stale_records = old_records - new_records #=> []
在项目重复时没有给出正确的结果。