From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 32C321F453 for ; Thu, 7 Feb 2019 07:36:05 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 37FB3121256; Thu, 7 Feb 2019 16:36:02 +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 9AE92121295 for ; Thu, 7 Feb 2019 16:35:59 +0900 (JST) Received: by filter0013p3iad2.sendgrid.net with SMTP id filter0013p3iad2-27093-5C5BDFDC-16 2019-02-07 07:35:56.577596508 +0000 UTC m=+131034.807595008 Received: from herokuapp.com (ec2-54-80-77-200.compute-1.amazonaws.com [54.80.77.200]) by ismtpd0008p1iad2.sendgrid.net (SG) with ESMTP id -Mk3s3pSStms-TRf5N4NLQ for ; Thu, 07 Feb 2019 07:35:56.552 +0000 (UTC) Date: Thu, 07 Feb 2019 07:35:57 +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: 66912 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-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6tma5+8tlg3rPWM+zoY3nUhFHUnF8MCWrKG8 C7fRIFp/JWden9UvRhqNZp17qS7tTp+nvhexdmR0ZXl/SyxGx6xl34vTf7lijD2OeDA6XEwEouQVDU V4ybuNDeTJ7TzYKhtClGO9gq6Uu43zNOO/spFyCV1Lg9yPJ9CSWBgCAUZg== X-ML-Name: ruby-core X-Mail-Count: 91458 Subject: [ruby-core:91458] [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). I still feel weird when I see `@` and `@1` etc. Maybe I will get used to it after a while. I need time. Matz. ---------------------------------------- Feature #4475: default variable name for parameter https://bugs.ruby-lang.org/issues/4475#change-76718 * 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/