From: Julian Leviston Date: 2009-02-12T10:31:58+09:00 Subject: Re: Array uniq Use uniq! Which modifies the receiver in place. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 12/02/2009, at 7:51 AM, 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) > > Many thanks > -- > Posted via http://www.ruby-forum.com/. >