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)
@objsobjs = []
@yield_valsyield_vals = []
self.each do |obj|
yield_val = yield obj
unless @yield_valsyield_vals.include?(yield_val)
@yield_valsyield_vals.push(yield_val)
@objsobjs.push(obj)
end
end
@objsobjs
end
end