From: Jeff Lunt Date: 2012-04-20T07:06:37+09:00 Subject: Re: finding duplicates in an array and its index number --90e6ba1ef486a654a404be0f6281 Content-Type: text/plain; charset=ISO-8859-1 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/. > > --90e6ba1ef486a654a404be0f6281 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

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-forum.com> wr= ote:
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/.

--90e6ba1ef486a654a404be0f6281--