From: Ulisses Reina Montenegro de Albuquerque Date: 2006-10-24T21:51:19+09:00 Subject: Re: How to remove empty element in an array On Tuesday 24 October 2006 00:02, Seth E. wrote: > Li Chen wrote: > > 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? > > How about this? > > irb(main):201:0> arr = [1,2,''] > => [1, 2, ""] > irb(main):202:0> arr -= [''] > => [1, 2] I am new to the list, and have so far tried to keep myself as a silent lurker hidden on the corner, but coming from a Perl background (5+ years) and seeing this beautiful piece of code really makes me feel confident about leaving old habits and joining the Ruby club. -- "The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man." (George Bernard Shaw)