From: buddhamagnet@... Date: 2008-08-25T21:22:09+09:00 Subject: Re: indices of non nil elements in an array That can be made even more elegant: a.reject (/e/ e.nil?) Apologies I am on an iPod so the brackets should be braces and the slashes pipes! Sent from my iPod On Aug 25, 2008, at 1:04 PM, "Patrick Doyle" wrote: > On Mon, Aug 25, 2008 at 7:54 AM, David A. Black > wrote: >> On Mon, 25 Aug 2008, Patrick Doyle wrote: >>> I'm sure there is some simple elegant way to do this, but I can't >>> figure >>> it out. >> >> Try this: >> >> (0...a.size).reject {|i| a[i].nil? } >> > Ahhh -- that's the simple elegant way for which I was searching. I > kept going down the path of a.each_index and didn't like where that > was going. > > --wpd >