From: Jeff Lunt Date: 2012-04-20T07:08:12+09:00 Subject: Re: finding duplicates in an array and its index number --20cf307d010c24169304be0f6811 Content-Type: text/plain; charset=ISO-8859-1 If you really want to know how it finds the duplicates, look at the source code for the .uniq method as a starting point. On Apr 19, 2012 5:06 PM, "Jeff Lunt" wrote: > I'm curious what the purpose is. If it's simply to remove the duplicates > you can call .uniq on the array to remove duplicates. > On Apr 19, 2012 4:55 PM, "newto ruby" wrote: > >> Hi, >> >> I have following array and I am trying to find if there are duplicates >> in the array. I also want to find out their index. >> >> e.g. >> >> a=[1,2,3,1,3] >> >> Here 1 is a duplicate which comes twice and its index is 0 and 3 in the >> array. >> >> Any suggestions? >> >> Thanks >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> --20cf307d010c24169304be0f6811 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

If you really want to know how it finds the duplicates, look at the sour= ce code for the .uniq method as a starting point.

On Apr 19, 2012 5:06 PM, "Jeff Lunt" &= lt;jefflunt@gmail.com> wrote:<= br type=3D"attribution">

I'm curious what the purpose is. If it's simply to remove the du= plicates you can call .uniq on the array to remove duplicates.

On Apr 19, 2012 4:55 PM, "newto ruby" = <lists@ruby-fo= rum.com> wrote:
Hi,

I have following array and I am trying to find if there are duplicates
in the array. I also want to find out their index.

e.g.

a=3D[1,2,3,1,3]

Here 1 is a duplicate which comes twice and its index is 0 and 3 in the
array.

Any suggestions?

Thanks

--
Posted via http://= www.ruby-forum.com/.

--20cf307d010c24169304be0f6811--