From: "David A. Black" Date: 2009-02-12T06:02:43+09:00 Subject: Re: Array uniq On Thu, 12 Feb 2009, Stuart Little wrote: > I am having some troubles with the uniq method for arrays. This is a > typical example of my data set, which I want to remove the duplicates > from. > > TueAug052008 > TueAug052008 > TueAug052008 > TueAug052008 > > Its clear to see the set of data above has 4 identical values and should > therefore only have remaining after applying array.uniq to this array. > It has become obvious this doesn't work and uniq doesn't remove any > duplicates it just pushes the data out as it finds it full of > dupelictes. Is this a problem with the data set? This is my code: > > value= timeDone.to_s > dateCheck.push value.gsub(/\s/, '')[0..7] + value[26..30] > date = dateCheck.uniq > @alerts.push(date) Array#uniq does work: >> a = Array.new(4) { "TueAug052008" } => ["TueAug052008", "TueAug052008", "TueAug052008", "TueAug052008"] >> a.uniq => ["TueAug052008"] So there must be something else going on. Maybe stray whitespace? How are you determining that the operation didn't work? David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!