From: "Jesús Gabriel y Galán" Date: 2009-02-04T05:55:09+09:00 Subject: Re: Hash counting On Tue, Feb 3, 2009 at 7:34 PM, Stuart Clarke wrote: > Thanks for getting back to me. > and get what is expected: > > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > WedAug062008 > WedAug062008 > > Its the next step counts.each do |id,cnt| which is the problem. Sorry, but can you post a complete executable piece of code we can use to reproduce the problem? You have this: eventdateID.push eventsbydate.gsub(/\s/, '')[0..7] + eventsbydate[26..30] but what is eventdateID? Maybe you have an earlier line of code like eventdateID = []. I'd like to see the complete picture. Also, what is eventsbydate? By the way, now I'm realizing that eventsbydate might be a string, so how can eventdateID contain more than 1 entry at all? If that's true, then eventsbydate.gsub(/\s/, '')[0..7] + eventsbydate[26..30] is also a string. So you are pushing a single string into eventdateID, so when you later iterate you only get one iteration. Perhaps you have a loop around the piece of code you showed? If that's the case, then it makes sense that you never get more than 1 count per entry, because you are creating the hash every time. So, I think it would be easier if you pasted the complete program. >> If each element in the array eventDateID is stored in the hash as a >> different key (which is what seems to be happening), maybe what is >> inside the array are not strings, but another class that has a >> different implementation of eql?. > > Not sure what you mean by this. It was another hipothesis, but I think you can forget about it, since I'm pretty sure now that with the piece of code you showed you are only ever pushing one string into eventdateID. Jesus.