From: Li Chen Date: 2006-10-24T03:02:21+09:00 Subject: Re: How to remove empty element in an array Joel VanderWerf wrote: > Farrel Lifson wrote: >> 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 > ... >> If you only want to get rid of empty strings >> array.reject{|element| element.empty?} > > array.reject{|element| element.empty? rescue false} Hi Joel, I come out with my own solution by using a regxp: a=[1,2,'',''] a.delete_if {|x| x=~/$/} p a ##output C:\Ruby\self>array3.rb [1, 2] -- Posted via http://www.ruby-forum.com/.