Array#count() : count() is a Array class method which returns the number of elements in the array. It can also find the total number of a particular element in the array.
Syntax: Array.count() Parameter: obj - specific element to found Return: removes all the nil values from the array.
Code #1 : Example for count() method
counting : 6 counting : 3 counting : 2
Code #2 : Example for count() method
counting: 3 counting : 0 counting : 2