Roelof Wobben wrote in post #1077503:
>   h = Hash.new(0)
>   dice.each {|el| dice[el] += 1}
> [...]
> But now I'm getting this error : undefined method `+' for nil:NilClass

You want h[el] += 1, not dice[el] += 1. See the original code by Jesús.