From: Farrel Lifson Date: 2006-10-24T02:34:21+09:00 Subject: Re: How to remove empty element in an array On 23/10/06, Li Chen wrote: > Hi all, > > I have an array of [1,2,''] I want change it to [1,2]. I check the > document about Array but I can't find a way to remove the empty element. > Any comments? > > Thanks, > > Li > > -- > Posted via http://www.ruby-forum.com/. > > If you only want to get rid of empty strings array.reject{|element| element.empty?} If you want to get rid of nils array.compact Farrel