From: Xavier Noria Date: 2008-08-25T20:38:01+09:00 Subject: Re: indices of non nil elements in an array On Mon, Aug 25, 2008 at 3:20 AM, Patrick Doyle wrote: > a = [] > a[10] = "foo" > > a.nitems returns a count of the non-nil, items. What is the simplest > way to return the indices of "a" that are not nil? Not exactly what you ask, but in case it's actually what you are after have a look at Array#compact.