From: Dan Doel Date: 2003-11-20T02:43:20+09:00 Subject: Re: x.f! RCR Michael Neumann wrote: >Your suggestion is that delete_if does not delete anything (it creates a new >array), where delete_if! would. Principle of Least Surprise? Not for me! > > That depends on your background, I suppose. If I'm not mistaken, ! and ? probably come from Scheme, where ! is usually used to denote that it causes a side effect on the arguments. Since Scheme advocates functional programming, (delete_if predicate list) would return a new list with the proper elements deleted, while (delete_if! predicate list) would delete the elements in place (probably returning the list as well). If you're writing in a functional manner, it's not at all surprising to expect a delete... or remove... function to not modify the initial list (in fact it's almost a requirement if you want to prove certain correctness requirements for a program). In that case, the fact that there is no #delete_if that doesn't modify the base list would be an inconvenience. Not that Ruby's lists are exactly suited for functional programming, but food for thought. Cheers. - Dan