Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!talisker.lacave.net!lacave.net!not-for-mail From: Thomas Greenwood Newsgroups: comp.lang.ruby Subject: Re: Counting how many times the same elements occurs in an array? Date: Sun, 15 May 2011 08:06:04 -0500 Organization: Service de news de lacave.net Lines: 23 Message-ID: References: <6a81112b3af069fa30e1c843c72f8be9@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1305465320 44385 65.111.164.187 (15 May 2011 13:15:20 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 15 May 2011 13:15:20 +0000 (UTC) In-Reply-To: <6a81112b3af069fa30e1c843c72f8be9@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383278 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4570 I'm sure your solutions are better than mine, what I ended up doing; xml_events = Array.new temp_array = Array.new [...] #extract xml data and assign it to the events array. [...] xml_events.each{|x| if temp_array.include?(x) == false temp_array << x puts "#{x} occurs #{xml_events.count(x)} times" end } A kludge but it does the job. Thanks for your help. -- Posted via http://www.ruby-forum.com/.