Project

General

Profile

Feature #7394

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

=begin 
 from github: 
 https://github.com/ruby/ruby/pull/186 

 In trunk the `Enumerable#find` Enumerable #find method `ifnone` ifnone parameter has to be callable or `nil`. nil. I found that sometimes I want to return a simple value without wrapping it in a proc. This pull request adds support for non-callable defaults when no items match. 

 ```ruby 
 a (({a = [1, 2, 3] 
 ``` 3]})) 

 The current behavior 

 ```ruby 
 a.find(proc (({a.find(proc { :foo }) { |x| x > 3 } #=> :foo 
 ``` :foo})) 

 With patch 

 ```ruby 
 a.find(0) (({a.find(0) { |x| x > 3 } #=> 0 0})) 
 ``` =end 

Back