From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id B1EC41F453 for ; Wed, 13 Feb 2019 22:07:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BB16D120D29; Thu, 14 Feb 2019 07:07:46 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 95AD4120C64 for ; Thu, 14 Feb 2019 07:06:39 +0900 (JST) Received: by filter0012p3iad2.sendgrid.net with SMTP id filter0012p3iad2-14341-5C6494ED-37 2019-02-13 22:06:37.748613797 +0000 UTC m=+66012.281480857 Received: from herokuapp.com (ec2-54-224-197-248.compute-1.amazonaws.com [54.224.197.248]) by ismtpd0045p1mdw1.sendgrid.net (SG) with ESMTP id 0KekBoevRzCHwptgV4-fPQ for ; Wed, 13 Feb 2019 22:06:37.714 +0000 (UTC) Date: Wed, 13 Feb 2019 22:06:38 +0000 (UTC) From: samuel@oriontransfer.net To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66988 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 7394 X-Redmine-Issue-Author: zzak X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: ioquatix X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5aG5p3Wqqn5DaBraFfuIRtgZn4rsoqgxeqK0 i3rY4CmGa37/VP2QD9ANzznmwR39QUf6fKsY+vNi8BjPA703M1OeWtXUs4JxDYLo+iHpbA4KmhTg6o Vw2uZo5Thl+q+d5QTobUbOFjYOHfnEFI/FGLdPr7PFkPVzSEdtwMHWw/Eg== X-ML-Name: ruby-core X-Mail-Count: 91536 Subject: [ruby-core:91536] [Ruby trunk Feature#7394] Enumerable#find ifnone parameter could be non-callable X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #7394 has been updated by ioquatix (Samuel Williams). Can we merge this? ---------------------------------------- Feature #7394: Enumerable#find ifnone parameter could be non-callable https://bugs.ruby-lang.org/issues/7394#change-76793 * Author: zzak (Zachary Scott) * Status: Assigned * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * Target version: ---------------------------------------- =begin 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. (({a = [1, 2, 3]})) The current behavior (({a.find(proc { :foo }) { |x| x > 3 } #=> :foo})) With patch (({a.find(0) { |x| x > 3 } #=> 0})) =end ---Files-------------------------------- enumerable_find_noncallable.patch (3.45 KB) -- https://bugs.ruby-lang.org/