On 23/10/06, Li Chen <chen_li3 / yahoo.com> 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