From: "David A. Black" Date: 2009-02-12T06:59:45+09:00 Subject: Re: Array uniq Hi -- On Thu, 12 Feb 2009, Stuart Little wrote: > Thanks for the response. > > I remove whitespace with gsub. My original data set: > > TueAug052008 > WedAug062008 > TueAug052008 > WedAug062008 > WedAug062008 > > Is returned after my code exactly the same, I am expecting > > WedAug062008 > TueAug052008 > > I have dumbed the code down to see what you think: > > time = event.time_written.to_s > dateCheck = [time.gsub(/\s/, '')[0..7] + time[26..29]] > printdata = [dateCheck] > @alerts.push printdata.uniq printdata.uniq is the same items as printdata, because printdata only contains one item. So you're doing this: dateCheck = ["string"] printdata = [["string"]] @alerts.push [["string"]].uniq I don't how deeply nested you want your arrays, but if @alerts is the final product and you want it uniq, you could run @alerts.uniq! at the end, or do something like: @alerts.push printdata unless @alerts.include?(printdata) 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!