Module: Enumerable

Instance Method Summary collapse

Instance Method Details

#uniqObject


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/puppet/util/monkey_patches.rb', line 130

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