From: Sam Kong Date: 2005-10-18T04:36:58+09:00 Subject: Re: How to get non-unique elements from an array? Hi! I'm the OP. I thank those who replied to my message. I learned a lot and seeing all different approaches was fun. Somebody emailed me with his own solution which I like very much. I want to share it with the group. a = [0,1,2,3,4,5,2,3] a.select{|e| a.index(e) != a.rindex(e)}.uniq It is very brief and still very easy to understand. Don't you think so? I wonder if my slightly modified version works. a.select{|e| a.grep(e).length > 1}.uniq grep is for pattern but seems to work fine for integers. I'm not sure though. (Simple tests show it works.) In my opinion, using regex is too much for this problem (maybe slower?). Array#inject seems to be good but I get confused whenever I come across it (maybe I'm not smart enough). What do you think? Thanks all! Sam