From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 131C520C11 for ; Tue, 28 Nov 2017 04:26:54 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 92846120930; Tue, 28 Nov 2017 13:26:50 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id ABE9E12092B for ; Tue, 28 Nov 2017 13:26:47 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=xJ5HSQRnuS8sgW1KJN5cFCl8PME=; b=DTaYEP7zjYzHt5u78+ aux6HlBz3IJBs8k8P72tDidFDIODGWVwomeC0sPCiPovzKhY29Fg0oXU/G2xixLt viZ4dcr3zj+JDA8tYKUu17UKsbuVDOhDSeNXxPwe1bJS1QrXq0FAkvaOca22Pkef lSYSZ35VDCUiXiMpCsjFIEdlc= Received: by filter0022p3iad2.sendgrid.net with SMTP id filter0022p3iad2-22786-5A1CE584-15 2017-11-28 04:26:44.346508949 +0000 UTC Received: from herokuapp.com (ec2-54-81-168-71.compute-1.amazonaws.com [54.81.168.71]) by ismtpd0025p1iad2.sendgrid.net (SG) with ESMTP id d6UPG1KPQOCHnpLPbu9vTQ Tue, 28 Nov 2017 04:26:44.410 +0000 (UTC) Date: Tue, 28 Nov 2017 04:26:45 +0000 (UTC) From: ruby-core@marc-andre.ca To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 59031 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11286 X-Redmine-Issue-Author: 0x0dea X-Redmine-Issue-Assignee: matz X-Redmine-Sender: marcandre 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5bHMxfBOn3tO9CwH0tvhWZBd277O8INBiKP5 lMXyUifhZGWCk32JlOpJfLOAHiAxLoKR3kyp0+gA1qDbS0MBB2W9ozSk/e6bCzIK+OPbbDGyMq8GhG qDj5/iMNxQodwLMAvZ7HhTNyElDL+aQ2XYWTlOzuvd04UEbBjUxv1kMNtA== X-ML-Name: ruby-core X-Mail-Count: 83904 Subject: [ruby-core:83904] [Ruby trunk Feature#11286] [PATCH] Add case equality arity to Enumerable's sequence predicates. 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 #11286 has been updated by marcandre (Marc-Andre Lafortune). matz (Yukihiro Matsumoto) wrote: > I am positive about the idea too. But as a duty of the final decision maker, I have to consider every option before the judgment. I see a few additional options. > > * takes optional argument that takes `===` (proposed) > * takes optional keyword argument, `match:` for example > * introduces another set of methods with different names > > Right now, I am wandering between option 1 and 2. I hope a decision is made on this. While I love keyword arguments in general, I am not convinced they are needed here and I would favor solution #1. ---------------------------------------- Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates. https://bugs.ruby-lang.org/issues/11286#change-67954 * Author: 0x0dea (D.E. Akers) * Status: Open * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- ## 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/