< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #11286 has been updated by D.E. Akers.
File case_equality_sequence_predicates-all_updates.patch added
I knew the call to `rb_check_arity()` should come first, but your very nice solution to doing so without mixing declarations and code did not occur to me. The attached contains all of the improvements discussed so far, but maybe there are more to be found? Is there something cleaner than passing `argc` to `ENUMFUNC()`?
----------------------------------------
Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates.
https://bugs.ruby-lang.org/issues/11286#change-53064
* 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)
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/