Module: Enumerable

Instance Method Summary collapse

Instance Method Details

#uniqObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/puppet/util/monkey_patches.rb', line 88

def uniq
  result = []
  uniq_map = {}
  if block_given?
    each do |value|
      key = yield value
      next if uniq_map.has_key?(key)
      uniq_map[key] = true
      result << value
    end
  else
    each do |value|
      next if uniq_map.has_key?(value)
      uniq_map[value] = true
      result << value
    end
  end
  result
end