From: Michael Neumann Date: 2001-04-08T22:35:31+09:00 Subject: [ruby-talk:13556] Re: array question OZAWA -Crouton- Sakuro wrote: > If you just want to count non-nil elements in a array, use compact. > > arr = Array.new > arr[1000] = 1 > puts arr.compact.size > #=> 1 > arr.compact! > puts arr.size > #=> 1 But then arr[1000] results in nil !!! -- Michael Neumann