From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 692DA19C0031 for ; Fri, 6 Nov 2015 06:24:56 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 77BAAB5D898 for ; Fri, 6 Nov 2015 06:53:57 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 843A318CC7B8 for ; Fri, 6 Nov 2015 06:53:57 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 323081204EA; Fri, 6 Nov 2015 06:53:55 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8CCE41204B3 for ; Fri, 6 Nov 2015 06:53:51 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=VocBxk6ZeaJUbpV/rS0jeLAOoRQ=; b=oKHT64lQtzzfIyLq/8 7diz0OKSnUM5m8jrTBiZQaqgtz5OoqXeOF5YiLJV99gRuLMF29uvwosFGhlgvha9 gVy0wivBHolNPSRBgCdpl42Ye2s1x7/Zc8cK/rBU5ODNeUf2hSU7/McPACBbxQJA fhAR+JsuMPdq5nsoPPD7/CW9s= Received: by filter-302.sjc1.sendgrid.net with SMTP id filter-302.9367.563BCFEA32 2015-11-05 21:53:46.569055024 +0000 UTC Received: from herokuapp.com (ec2-107-22-66-12.compute-1.amazonaws.com [107.22.66.12]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id XmR4peDvQ-am4SqqI3CMYQ for ; Thu, 05 Nov 2015 21:53:46.638 +0000 (UTC) Date: Thu, 05 Nov 2015 21:53:46 +0000 From: shannonskipper@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45998 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11286 X-Redmine-Issue-Author: 0x0dea X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shan 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS6qoXT8qiuAwUDfAHfg8ArCT9/xHHzzVm2jmj xMnzR3aowtEX85j+vJuAn7nFS0VmsacPSnjSQnkm0PdaVO/dUJjB6SpH07rRbEji2xpX0t2hi3aWNX OU4FsEuJnR0Twbw= X-SendGrid-Contentd-ID: {"test_id":"1446760427"} X-ML-Name: ruby-core X-Mail-Count: 71357 Subject: [ruby-core:71357] [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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11286 has been updated by Shannon Skipper. This seems quite nice. Any downsides? ---------------------------------------- Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates. https://bugs.ruby-lang.org/issues/11286#change-54722 * Author: D.E. Akers * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- ## 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/