Select! not present but reject! is

Gavin Sinclair wrote:

scratch, they'd be a little cleaner than they are now. [1] That is

I was going to add a footnote, thought better of it, and forgot to
remove the "[1]". Apologies for the additional noise.

Gavin

Hi --

Hal Fulton wrote:

It's not a matter of the English language as such -- English is just
the language that the keywords and method names are based on.

I oppose select! not on the basis on English purity, but on that of
Ruby purity.

Can you justify that opposition in the context of the following Array
methods?

collect! compact! flatten! map! reject! reverse!
slice! sort! uniq!

I'm not sure what you mean by the context of those methods. It's just
a question of whether select! is a good name for the proposed
behavior.

I've read the whole thread (perhaps too quickly), and don't see what at
all is controversial about #select! as an in-place #select.

Read it less quickly :slight_smile: My problem with it is that "a dangerous
version of select" doesn't evoke this behavior to me, and "an in-place
version of select" I find meaningless. I consider "select"
fundamentally a benign operation, not an operation that can either
have or not have dangers associated with it. See thread for more.

[...]

Finally, FWIW, here's a list of Array methods that _don't_ have an
in-place counterpart (including Enumerable methods):

find_all grep sort_by

Gee, not many! (Especially as #find_all is just #select.) As a lover
of minutae, I'd like to hear people's arguments for and against banging
these :slight_smile: (ooh errrr)

find_all! and grep! don't seem to mean anything, other than "Tell me
which elements pass this test -- *really* tell me!" sort_by! would be
useful (or, as we've joked on irc, sort!_by :slight_smile:

David

···

On Sun, 9 Oct 2005, Gavin Sinclair wrote:

--
David A. Black
dblack@wobblini.net

Not to hijack the thread, but I secretly pine for sort_by!(). I swear I've never used it when it wasn't like:

arr = arr.sort_by { ... whatever ... }

James Edward Gray II

P.S. I have no problem at all with select!(). Honestly, the English seems fine to me. It's a real word and I know what it means. It's certainly more English than extname(), callcc(), nitems(), etc.

···

On Oct 9, 2005, at 6:56 AM, Gavin Sinclair wrote:

Finally, FWIW, here's a list of Array methods that _don't_ have an
in-place counterpart (including Enumerable methods):

  find_all grep sort_by

Not to add to the highjacking, but I agree. In fact, if I had to
prioritize which should be added first, sort_by! would be higher than
select!.

And to address David's note about delete_if and reject! not quite
being synonyms, true, so therefore keep_if and select! should have
similar semantics.

Ryan

···

On 10/9/05, James Edward Gray II <james@grayproductions.net> wrote:

Not to hijack the thread, but I secretly pine for sort_by!(). I
swear I've never used it when it wasn't like:

arr = arr.sort_by { ... whatever ... }