From: Gavin Sinclair Date: 2009-12-25T15:20:26+09:00 Subject: [ruby-core:27321] Re: select! On Fri, Dec 25, 2009 at 12:05 PM, Ryan Davis wrote: >> As a datum: I've frequently typed select! in the past, expecting it to >> be there, so it _is_ useful to me. �(I then add it myself, of course, >> but curse having to do so.) > > I still don't think the concept makes sense. Sure, you seem to want to use it, but in the same vain do you also reach for delete_if's opposite? > > �ary.delete_unless { ... } No, but how it that in the same vein? I don't use delete_if (I much prefer the method name 'reject') and I wouldn't use delete_unless either, whereas I like, understand and have frequently used select!. I guess what I'm saying is this: I don't think of select! in terms of opposites (as in "I use reject! so I'll also use select!"). It's just as in-place version of "select", as the name implies. I don't want to labour the point, but this is my typical use case: Code starts out as something like result = collection.map { |x| ... }.select { |x| ... } But then I might add code to the "map" part, and the code now extends over a few lines and looks poor if it's chained together. So it gets changed to: result = collection.map { |x| ... ... ... } result.select! { |x| ... } -- Gavin Sinclair