I've implemented a working version of Array#uniq in Ruby to answer the question here: http://www.rubeque.com/problems/like-a-snowflake, but I'd like to see if there's ways to clean up my code or some better practices I should follow? This is my version:
class Array
def uniq(&block)
objs = []
yield_vals = []
self.each do |obj|
yield_val = yield obj
unless yield_vals.include?(yield_val)
yield_vals.push(yield_val)
objs.push(obj)
end
end
objs
end
end