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.8 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS 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 518B21F424 for ; Thu, 19 Apr 2018 11:42:49 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7DC061209D7; Thu, 19 Apr 2018 20:42: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 4DACA1209D2 for ; Thu, 19 Apr 2018 20:42:44 +0900 (JST) Received: by filter0021p3iad2.sendgrid.net with SMTP id filter0021p3iad2-14248-5AD880B0-18 2018-04-19 11:42:40.658286743 +0000 UTC Received: from herokuapp.com (ec2-54-205-82-39.compute-1.amazonaws.com [54.205.82.39]) by ismtpd0008p1iad1.sendgrid.net (SG) with ESMTP id cVUI1z-OQ56eOq1UVh3Otg Thu, 19 Apr 2018 11:42:40.437 +0000 (UTC) Date: Thu, 19 Apr 2018 11:42:41 +0000 (UTC) From: matz@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 61956 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 4475 X-Redmine-Issue-Author: jordi X-Redmine-Issue-Assignee: matz X-Redmine-Sender: matz 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-CSA-Complaints: whitelist-complaints@eco.de X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5RgdHSpPUPe4RdCymcVMgqXyUNK9I9gtoRMb KMqRMRkWAyOEZNR9xY+onECbjmWuxxgkRb2uguwVJx0ltntwxn16OHt6IEtv72RcPAjuQU61OZm/Fv X82l6zHl9NlsFkmT5WW0DO4EWaPFmyPJraKu5NeJuAQ8GgM5wEWhXkS8MQ== X-ML-Name: ruby-core X-Mail-Count: 86607 Subject: [ruby-core:86607] [Ruby trunk Feature#4475] default variable name for parameter 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 #4475 has been updated by matz (Yukihiro Matsumoto). This is a very interesting idea but at the same time, it's difficult to keep compatibility. At least simple addition of `it` does not work well. Matz. ---------------------------------------- Feature #4475: default variable name for parameter https://bugs.ruby-lang.org/issues/4475#change-71564 * Author: jordi (jordi polo) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- =begin There is a very common pattern in Ruby: object.method do |variable_name| variable_name doing something end Many times in fact the name of the object is so self explanatory that we don't care about the name of the variable of the block. It is common to see things like : @my_sons.each { |s| s.sell_to_someone } or Account.all.each { |a| my_account << a.money } People tend to choose s or a because we have the class or the object name just there to remind you about the context. I would like to know if can be a good idea to have a default name for that parameter. I think it is Groovy that does something like: Account.all.each { my_account << it.money } Where it is automagically filled and it doesn't need to be declared. I think it is as readable or more (for newbies who don't know what is ||) and we save some typing :) =end -- https://bugs.ruby-lang.org/