From: Michael Garriss Date: 2003-09-19T23:02:06+09:00 Subject: Re: Removing "nil" entries from array Thomas Adam wrote: >Dear All, > >I have a really weird situation. I'm reading a file into an array, based >on a grep match. This works fine..... > >...yet I re-ran my program using the same data file (unchanged) and now my >array is being intermittently populated with "nil" values. Using "uniq()" >doesn't remove them. Any ideas? > > > [1, nil, 2, nil, 3, nil, 4].compact! --> [1, 2, 3, 4] ....or you could use #compact if you don't want to change the array in place. Regards, Michael