select! not present but reject! is

G

Gavin Sinclair

Gavin said:
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
 
D

David A. Black

Hi --

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 :) 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 :) (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 :)


David
 
J

James Edward Gray II

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

Ryan Leavengood

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 =3D arr.sort_by { ... whatever ... }

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top