From: "Jesús Gabriel y Galán" Date: 2012-09-25T17:55:10+09:00 Subject: Re: inject problem On Tue, Sep 25, 2012 at 10:41 AM, Roelof Wobben wrote: > Hello, > > I have a array like this [ 1.2.1.1] Well, first of all this is not correct. It should be: count = [1,2,1,1] > Now I want a hash which contains the numbers and the count. > So I thought this would work : count.inject { |1, array.count(1)| } This doesn't even make sense to me. > But I get a lot of syntax errors. > > Can anyone give me a hint where I am going wrong ? If you want to do that you need to create a Hash. Then iterate through the array adding 1 to the value in the hash for each element of the array. Jesus.