M
Martin DeMello
Here is your problem. Hash.new(0) means "when I query the hash, and
the key I request is not in there, return 0". It does not actually add
{key =3D> 0} to the hash itself.
This is true, but counts[d] +=3D 1 is actually counts[d] =3D counts[d] + = 1
so the RHS will evaluate to 1 the first time, assigning it to the hash:
Oops - yes, missed that.
martin