a = [1,1,2,3,5,8] a.count(1) # => 2: two elements equal 1 a.count {|x| x % 2 == 1} # => 4: four elements are odd