Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要遍历一个名为@ads 的数组并删除其中所有相互重复的对象。我该怎么做呢?
@ads = @ads.uniq
或者
@ads.uniq!
下面的代码将通过 id 为您提供唯一的结果。
@ads = @ads.uniq{|ad| ad.id}