Hi if i want to count the number of times values are repeated in an
array how do i go about it...is there a method?

My solution is

list.sort
loop through list and compare one element to the next and count
repetitions.

is there a simpler way?

Also

in C i used the for loop a lot to loop through arrays but i notice that
in ruby using
list.each do |element|
..
..
end

is quite popular.

 If i wanted to do someting like this:

if list[currElement] == list[currElement + 1]
...

How would i go about writing that using list.each do |element|?

Any help greatly appreciated.
-- 
Posted via http://www.ruby-forum.com/.