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 (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id F296F1B0006A for ; Fri, 7 Oct 2016 05:56:40 +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 F3EECB5D919 for ; Fri, 7 Oct 2016 06:28:20 +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 134E818D1D32 for ; Fri, 7 Oct 2016 06:28:21 +0900 (JST) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 8F79D1205C7; Fri, 7 Oct 2016 06:28:19 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3AF441204D9 for ; Fri, 7 Oct 2016 06:28:14 +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=kr8wTfWFSlOvSXr7A7qd9x3rmY4=; b=QScexaQzcy71CY2raK bFzs4pnTj6bDfnenfrkxb6+R8vaj0db/J3aMAUPgaGxYw40daxjZS6jAV4/QLs2T ZoBU2wr4kFo9IwNS4i3pLJOo1WD82iivi9IwKkrEvYFalAF2O+o3BZMe9nDejK1n eM/8OmbzWSLcZsOQDuuxleSnk= Received: by filter0454p1mdw1.sendgrid.net with SMTP id filter0454p1mdw1.1469.57F6C1E01E 2016-10-06 21:28:00.615051633 +0000 UTC Received: from herokuapp.com (ec2-54-159-71-61.compute-1.amazonaws.com [54.159.71.61]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id -g4B4rDVRNmY4nDs-Kc5Wg Thu, 06 Oct 2016 21:28:00.477 +0000 (UTC) Date: Thu, 06 Oct 2016 21:28:00 +0000 From: shevegen@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 52355 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11286 X-Redmine-Issue-Author: 0x0dea X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shevegen 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4gy93rvC4ft04XklYhjhCktPTftx+mxWhLru +Vi+KLIgjD+BUs0G35uP+G9ViGRD9lKH0HoY58BQRVNezb9XmcFyTfdA9L8IzX3ijvqsjxgW/YhMbn pLf8AkBGqnNWNXUfd2DVAA9vaPRZe8IZO/xMUk5NhHmYdXkZzvQ3w4jujQ== X-ML-Name: ruby-core X-Mail-Count: 77508 Subject: [ruby-core:77508] [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 Robert A. Heiler. I like this one in particular: some_strings.none?(/aeiou/i) I am not so sure about: nums.grep(5..10) But I have no strong feelings either way. I do disagree with the statement "syntactic noise incurred by opening a block" though - blocks feel very natural in ruby to me. I guess the main part I would agree is that the .grep(range) variant is shorter to write than the block variant. This also reminds me of other proposals about allowing arguments to e. g. .map(&:chomp) invocations - I use this quite a lot myself but the & there still "feels" sort of strange. ---------------------------------------- Feature #11286: [PATCH] Add case equality arity to Enumerable's sequence predicates. https://bugs.ruby-lang.org/issues/11286#change-60770 * 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/