目前我正在做以下事情,并想知道是否有合并方法?
merged = list_with_objects_that_have_url_and_name_attributes
merged = merged.uniq{|ex| ex.url }
merged = merged.uniq{|ex| ex.name }
我想要像:
merged.uniq{|ex| ex.name || ex.url}
答案 0 :(得分:2)
不是你要求的,但它是紧凑的:
merged.uniq!(&:url).uniq!(&:name)