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.1 required=3.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_MED,SPF_PASS,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 0E0E31F404 for ; Thu, 1 Feb 2018 23:13:20 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4B8181209C1; Fri, 2 Feb 2018 08:13:16 +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 7901212095F for ; Fri, 2 Feb 2018 08:13:14 +0900 (JST) Received: by filter0016p3las1.sendgrid.net with SMTP id filter0016p3las1-19306-5A739F06-2E 2018-02-01 23:13:10.520651109 +0000 UTC Received: from herokuapp.com (ec2-54-226-142-85.compute-1.amazonaws.com [54.226.142.85]) by ismtpd0045p1mdw1.sendgrid.net (SG) with ESMTP id jtGwT65tQMe19nGWo81yeQ Thu, 01 Feb 2018 23:13:10.148 +0000 (UTC) Date: Thu, 01 Feb 2018 23:13:11 +0000 (UTC) From: nobu@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 60607 X-Redmine-Project: common-ruby X-Redmine-Issue-Id: 13581 X-Redmine-Issue-Author: americodls X-Redmine-Sender: nobu 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7SYMkkeXkULkEUk55hvX5Z0PXYfzmf9tzEVe sG1ifKjGW3S31A5R6T5pwoOt/xZ7xWt+qAYW+m51lsdjx0pnQaOMUfjx/un3QaRGaWzsMfaKTjkDQe 5mJdOqjOUb6pvbx7qhkP8/lvzVSnwp2zjKBPVx8QrYcToiLEi48bAlFYUg== X-ML-Name: ruby-core X-Mail-Count: 85330 Subject: [ruby-core:85330] [CommonRuby Feature#13581] Syntax sugar for method reference 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 #13581 has been updated by nobu (Nobuyoshi Nakada). mpapis (Michal Papis) wrote: > Not sure it's worth it - but while we are at this thinking of a shorthand one of the proposals `&Math&>sqrt` made me think if it could be automated and all the iterators could recognize methods and we could avoid the initial `&` to this `map(Math...)` - skipped the operator as it's not clear what's preferred. It can't distinguish passing block and passing `Method` object. > My two cents to the operator - what about `!` and `@` would they conflict? (yes for the Kernel, not sure about Class'es). `Math!sqrt` and `Math@sqrt`? They are valid syntax now. You can try with `ruby -c`. ``` $ ruby -wc -e 'Math!sqrt' Syntax OK $ ruby -wc -e 'Math@sqrt' Syntax OK ``` They are interpreted as a method call without a receiver, `Math(!sqrt)` and `Math(@sqrt)` respectively. ---------------------------------------- Feature #13581: Syntax sugar for method reference https://bugs.ruby-lang.org/issues/13581#change-70116 * Author: americodls (Americo Duarte) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Some another programming languages (even Java, in version 8) has a cool way to refer a method as a reference. I wrote some examples here: https://gist.github.com/americodls/20981b2864d166eee8d231904303f24b I miss this thing in ruby. I would thinking if is possible some like this: ~~~ roots = [1, 4, 9].map &Math.method(:sqrt) ~~~ Could be like this: ~~~ roots = [1, 4, 9].map Math->method ~~~ What do you guys thinking about it? -- https://bugs.ruby-lang.org/