Get uniq objects from data in Ruby

Some times we need uniq objects while performing complex operations
and avoid duplicate..

def make_uniq_by(&blk)
	object_set = []
	self.select do |el|
		only_uniq_objects = !object_set.include?(data=blk[el])
		object_set << data
		only_uniq_objects
	end
end

Thanks …. Feedback and suggestion are welcome..

Advertisements