J
Jimmy Kofler
Duplicates can also be extracted from an array like this:
class Array
def find_dups
uniq.map {|v| (self - [v]).size < (self.size - 1) ? v : nil}.compact
end
end
(The faster, the better; http://snippets.dzone.com/posts/show/4148 )
Cheers,
j.k.
class Array
def find_dups
uniq.map {|v| (self - [v]).size < (self.size - 1) ? v : nil}.compact
end
end
(The faster, the better; http://snippets.dzone.com/posts/show/4148 )
Cheers,
j.k.