On Thu, Dec 24, 2009 at 10:19 AM, David A. Black <dblack / rubypal.com> wrote=
:

>> |Is there any reason there's no select!
>>
>> Enumerables cannot have bang method, since they are not always
>> mutable. =A0The reason we don't have Array#select! is that I feel the
>> word select means picking up elements, not removing non-selecting
>> elements. =A0But I once felt same way to map! and (English speaking)
>> people persuaded me, so same thing could happen on select! as well.
>
> I agree with you. The idea of a destructive select makes no sense to
> me. Selecting implies that there's a result set that's separate from
> the original collection.

I think it's fine.  It's an aggressive selection, like selecting a
sports team from a squad of available players.

> "keep" might be a better name for an operation that's a kind of
> reverse reject!.

It seems wrong to me to invent new names when there's already a logical one=
.

  reject   reject!
  select    ???

It's obvious what should go there, whether it's immediately appealing or no=
t.

The least you can say is that it's perfectly clear (from the name)
what select! would do if it existed.

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.)

--
Gavin Sinclair