Forum: Ruby-core [Feature #2515] Array#select!

Posted by Marc-Andre Lafortune (Guest)
on 2010-03-02 06:40
(Received via mailing list)
Issue #2515 has been updated by Marc-Andre Lafortune.

Category set to core
Target version set to 1.9.x

I would suggest that this feature request be extended to also introduce 
Array#keep_if.

Indeed, Enumerable#reject has two corresponding in-place Array methods: 
Array#delete_if and Array#reject!

I feel that Enumerable#select would benefit from also having two 
in-place Array methods: Array#keep_if and Array#select!

The same difference would apply: select! returns nil if no change is 
made.

I feel the name select! is as appropriate as map! , collect! and reject!
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2515
Posted by Yukihiro Matsumoto (Guest)
on 2010-03-02 20:25
(Received via mailing list)
Hi,

In message "Re: [ruby-core:28398] [Feature #2515] Array#select!"
    on Tue, 2 Mar 2010 14:39:39 +0900, Marc-Andre Lafortune 
<redmine@ruby-lang.org> writes:

|I feel the name select! is as appropriate as map! , collect! and reject!

Okay, okay.  I understand your feeling.

|I would suggest that this feature request be extended to also introduce Array#keep_if.

The biggest reason (for me at least) was lack of counterpart of
delete_if, so if keep_if could gain consensus, I'd agree with adding
select! (and keep_if).  I was thinking of delete_unless, but was not
satisfied by the name.

              matz.
Posted by Roger Pack (Guest)
on 2010-03-02 23:13
(Received via mailing list)
> The biggest reason (for me at least) was lack of counterpart of
> delete_if, so if keep_if could gain consensus, I'd agree with adding
> select! (and keep_if).  I was thinking of delete_unless, but was not
> satisfied by the name.

+1 for keep_if from me.  Seems like a good name.

-rp
Posted by Yusuke ENDOH (Guest)
on 2010-03-03 04:49
(Received via mailing list)
Hi,

2010/3/3 Yukihiro Matsumoto <matz@ruby-lang.org>:
> |I would suggest that this feature request be extended to also introduce Array#keep_if.
>
> The biggest reason (for me at least) was lack of counterpart of
> delete_if


It's a revelation...  In [ruby-core:27254], you only said the reason
was the inappropriate name.

Anyway, good, I'm happy since the ticket will be closed positively :-)

+1 for keep_if
Posted by Yukihiro Matsumoto (Guest)
on 2010-03-03 06:42
(Received via mailing list)
Issue #2515 has been updated by Yukihiro Matsumoto.

Status changed from Open to Closed
% Done changed from 0 to 100

This issue was solved with changeset r26800.
Roger, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/2515
Posted by Roger Pack (Guest)
on 2010-03-04 20:16
(Received via mailing list)
Issue #2515 has been updated by Roger Pack.


Many thanks!
-rp
----------------------------------------
http://redmine.ruby-lang.org/issues/show/2515
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.