We have an array,
a = [1,2,3,2,4,5,2]
Now, I need to get the occurrence of each element in the ruby array one by one. So, here the ocuurrence of element '1' is 1 times. Occurrence of '2' is 3 times and so on.
Edited and added the below line later as most of the answers were submitted misinterpreting my question:
That means, I need to take the occurrence of a single element at a time.
How I could get the count?