ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shyouhei@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:78785] [Ruby trunk Feature#11286] [PATCH] Add case equality arity to Enumerable's sequence predicates.
Date: Wed, 21 Dec 2016 14:56:52 +0000	[thread overview]
Message-ID: <redmine.journal-62192.20161221145652.d570f578138ec867@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11286.20150619071155@ruby-lang.org

Issue #11286 has been updated by Shyouhei Urabe.


We looked at this issue in today's developer meeting.

Attendees were positive about the proposed functionality.  But Matz wanted separate method(s) than to extend all? etc, like we have separate select and grep methods.

----------------------------------------
Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates.
https://bugs.ruby-lang.org/issues/11286#change-62192

* Author: D.E. Akers
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Target version: 
----------------------------------------
## Proposal
It is proposed that `Enumerable`'s sequence predicates (`#all?`, `#any?`, `#none?`, and `#one?`) be augmented to return, in the case of a single argument, whether their query holds when each element is supplied to the argument's `#===` method.

## Rationale
`Enumerable#grep` filters by case equality, allowing us to write very natural and expressive code:

```ruby
strs.select { |str| /foo/ === str }
strs.grep(/foo/)

nums.select { |num| (5..10) === num }
nums.grep(5..10)
```

In addition to taking advantage of the versatility of case equality, it lets us do away with the syntactic noise incurred by opening a block. `#grep` is a very nice method! Let's make `#all?` and friends more like `#grep`.

---Files--------------------------------
0001-enum.c-add-case-equality-arity-to-sequence-predicates.patch (10 KB)
case_equality_sequence_predicates-check_argc_before_deref.patch (10 KB)
case_equality_sequence_predicates-all_updates.patch (9.94 KB)


-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2016-12-21 14:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11286.20150619071155@ruby-lang.org>
2015-06-19  7:11 ` [ruby-core:69675] [Ruby trunk - Feature #11286] [Open] [PATCH] Add case equality arity to Enumerable's sequence predicates 0x0dea+redmine
2015-06-19  8:48 ` [ruby-core:69678] [Ruby trunk - Feature #11286] " ryand-ruby
2015-06-19 14:22 ` [ruby-core:69682] " ruby-core
2015-06-19 21:54 ` [ruby-core:69685] " nobu
2015-06-19 22:14 ` [ruby-core:69687] " 0x0dea+redmine
2015-06-20  0:12 ` [ruby-core:69688] " nobu
2015-06-20  1:13 ` [ruby-core:69689] " 0x0dea+redmine
2015-07-16 17:30 ` [ruby-core:70004] " 0x0dea+redmine
2015-11-05 21:53 ` [ruby-core:71357] " shannonskipper
2015-11-05 22:09 ` [ruby-core:71358] " 0x0dea+redmine
2016-10-06  0:22 ` [ruby-core:77492] [Ruby trunk Feature#11286] " ryand-ruby
2016-10-06 21:28 ` [ruby-core:77508] " shevegen
2016-12-21 14:56 ` shyouhei [this message]
2016-12-21 16:03 ` [ruby-core:78787] " matz
2017-11-28  4:26 ` [ruby-core:83904] " ruby-core
2017-11-29  9:37 ` [ruby-core:83969] " matz
2017-12-10 22:41 ` [ruby-core:84150] [Ruby trunk Feature#11286][Closed] " ruby-core

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-62192.20161221145652.d570f578138ec867@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).