Hi,

I don't understand what you're saying.

OK, you have a given number n. Are you looking for all elements that 
occur *at least* n times in the array?

To count the number of occurences, you can use Enumerable#inject:

array = [1, 2, 2, 3, 2, 5]
element = 2
element_count = array.inject 0 do |count, x|
  count + (x == element ? 1 : 0)
end

Or a more lowlevel solution:

array = [1, 2, 2, 3, 2, 5]
element = 2
element_count = 0
array.each do |x|
  element_count += 1 if x == element
end

-- 
Posted via http://www.ruby-forum.com/.