提交 59ba8006 编写于 作者: A Aaron Patterson

refactoring uniq method

上级 7ebd36d1
......@@ -332,13 +332,10 @@ def many?
end
def uniq(collection = self)
seen = Set.new
collection.map do |record|
unless seen.include?(record.id)
seen << record.id
record
end
end.compact
seen = {}
collection.find_all do |record|
seen[record.id] = true unless seen.key?(record.id)
end
end
# Replace this collection with +other_array+
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册