Project

General

Profile

Feature #17333

Updated by okuramasafumi (Masafumi OKURA) over 3 years ago

`Enumerable#many?` method is implemented in ActiveSupport. 
 https://api.rubyonrails.org/classes/Enumerable.html#method-i-many-3F 
 However, it's slightly different from Ruby's core methods such as `one?` or `all?`, where they take pattern argument. 
 I believe these methods should behave the same so that it's easier to guess and learn. 

 We already have `none?`, `one?`, `any?` and `all?`, which translate into `== 0`, `== 1`, `> 0` and `== self.size`. 
 `many?` method translates into `> 1`, which is reasonable to exist. 
 Currently we need to write something this: 

 ```ruby 
 [1, 2, 3].count(&:odd?) > 1 
 ``` 

 With `many?`, we can make it much simpler: 

 ```ruby 
 [1, 2, 3].many?(&:odd?) 
 ```

Back