ruby冒泡算法删除店铺下的重复评论
1 Shop.each do |shop| 2 if !shop.comments.blank? 3 n = shop.comments.length 4 for i in 0..n-1 5 for j in i+1..n-1 6 if shop.comments[i].content == shop.comments[j].content 7 shop.comments[j].destroy 8 end 9 end 10 end 11 end 12 end
以上为ruby冒泡算法删除店铺下的重复评论代码