From: nobu@... Date: 2019-02-14T04:44:47+00:00 Subject: [ruby-core:91542] [Ruby trunk Feature#7394] Enumerable#find ifnone parameter could be non-callable Issue #7394 has been updated by nobu (Nobuyoshi Nakada). Description updated Currently, it is not able to distinguish from the case a hash is given as an ordinal argument. So there still is a possibility to break a compatibility. ---------------------------------------- Feature #7394: Enumerable#find ifnone parameter could be non-callable https://bugs.ruby-lang.org/issues/7394#change-76805 * Author: zzak (Zachary Scott) * Status: Assigned * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * Target version: ---------------------------------------- from github: https://github.com/ruby/ruby/pull/186 In trunk the `Enumerable#find` method `ifnone` parameter has to be callable or `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 = [1, 2, 3] ``` The current behavior ```ruby a.find(proc { :foo }) { |x| x > 3 } #=> :foo ``` With patch ```ruby a.find(0) { |x| x > 3 } #=> 0 ``` ---Files-------------------------------- enumerable_find_noncallable.patch (3.45 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: