From: Joel VanderWerf Date: 2004-07-06T08:58:06+09:00 Subject: Re: Array::index and rindex operator George Ogata wrote: > Hadmut Danisch writes: > > >>Hi, >> >>the Array::index and rindex functions >> >> arr.index( anObject ) -> anInteger or nil >> Return the index of the first/last object in arr such that the >> object == anObject. Returns nil if no match is found. >> >> >> >>Wouldn't it be better to have >> >> such that anObject === object ? > > > > I'm not so sure about that; #=== is primarily meant for case > statements, and very few methods use it like the way you propose. It > would also separate it from other Array/Enumerable methods like #find, > #delete, #include?, etc. > > Sometimes though I wish that #index could take a block (i.e., return > the first index for which the block is true). Unless I'm overlooking > something, there doesn't seem to be a method that does this. I don't > know what others think of the idea, but that would probably go some > way towards your goal. Enumerable#grep does use #===, so maybe what the OP wants is something like grep but instead of returning the matching value returns the index.