From: "trans. (T. Onoma)" Date: 2004-12-10T05:24:42+09:00 Subject: Re: String#split behaves odd On Thursday 09 December 2004 02:04 pm, David A. Black wrote: | Hi -- | | On Fri, 10 Dec 2004, trans. (T. Onoma) wrote: | > On Thursday 09 December 2004 12:29 pm, Ibraheem Umaru-Mohammed wrote: | > | ++ trans. (T. Onoma) [ruby-talk] [10/12/04 00:43 +0900]: | > | > That reminds me, do we have simple way to delete all empty strings | > | > from an array, like compact is for nil? | > | | > | what's wrong with using Array#delete ? | > | | > | --ibz. | > | > Right. I was thinking #delete only removed the first match it came to. | > But no, it does remove them all. So simple enough. Thanks. | > | > BTW, I mis-tested Florian's example so disregard my last post on the | > subject -- I see the point now. | | Small caveat: remember that Array#delete returns the thing deleted, | not the array, so you can't chain it as you would #compact. Good catch. Enough reason to have something for it, I think. I may add a general method to my libs: class Array def compact_on(n=nil) if n delete(n) else compact end self end end Better name? Or better solution? T.