Constrain the number of occurrences in an array

In reply to Bahaa Osman:

Casting works correctly . But i would want to understand why ? Doesnt item.e == ADD → 1