ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69685] [Ruby trunk - Feature #11286] [PATCH] Add case equality arity to Enumerable's sequence predicates.
Date: Fri, 19 Jun 2015 21:54:13 +0000	[thread overview]
Message-ID: <redmine.journal-53061.20150619215412.abbeabc44b289019@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11286.20150619071155@ruby-lang.org

Issue #11286 has been updated by Nobuyoshi Nakada.


> ~~~diff
> +    struct MEMO *memo = MEMO_NEW(Qtrue, *argv, 0);
> +    rb_check_arity(argc, 0, 1);

Why dereference `argv` before checking `argc`.

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

* Author: D.E. Akers
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
## 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)


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

  parent reply	other threads:[~2015-06-19 21:31 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 ` nobu [this message]
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 ` [ruby-core:78785] " shyouhei
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-53061.20150619215412.abbeabc44b289019@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).