From: Gavin Sinclair Date: 2004-12-10T06:43:09+09:00 Subject: Re: String#split behaves odd On Friday, December 10, 2004, 7:24:42 AM, trans. wrote: > | 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? Array#compact It doesn't currently take a parameter, so allow it to take one. FWIW I think Array#delete should be deprecated, and Array#compact extended in this fashion. I don't see a good rationale for the return value of Array#delete, and when a method is called #delete there is always confusion about whether it's destructive. Ruby spoils us so much that when you have to look something up in the docs a few times you feel cheated :) Gavin