[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78787] [Ruby trunk Feature#11286] [PATCH] Add case equality arity to Enumerable's sequence predicates.
From:
matz@...
Date:
2016-12-21 16:03:50 UTC
List:
ruby-core #78787
Issue #11286 has been updated by Yukihiro Matsumoto.
I am positive about the idea too. But as a duty of the final decision maker, I have to consider every option before the judgment. I see a few additional options.
* takes optional argument that takes `===` (proposed)
* takes optional keyword argument, `match:` for example
* introduces another set of methods with different names
Right now, I am wandering between option 1 and 2.
Matz.
----------------------------------------
Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates.
https://bugs.ruby-lang.org/issues/11286#change-62195
* 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/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>