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=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=no 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 0F24B20248 for ; Fri, 22 Mar 2019 00:19:12 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 56AC81214BE; Fri, 22 Mar 2019 09:19:06 +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 5072A121167 for ; Fri, 22 Mar 2019 09:19:04 +0900 (JST) Received: by filter0163p3mdw1.sendgrid.net with SMTP id filter0163p3mdw1-984-5C9429F7-E 2019-03-22 00:19:03.262113737 +0000 UTC m=+278599.662726525 Received: from herokuapp.com (unknown [54.158.50.190]) by ismtpd0018p1iad2.sendgrid.net (SG) with ESMTP id fw0bTQQyQRq8o2jxjsmCag for ; Fri, 22 Mar 2019 00:19:03.077 +0000 (UTC) Date: Fri, 22 Mar 2019 00:19:03 +0000 (UTC) From: harlemsquirrel@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67405 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 4475 X-Redmine-Issue-Author: jordi X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: HarlemSquirrel 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: =?us-ascii?Q?kR772M5n9zUj5=2FQNlyNn2LtCpxaJ7MlAg67bXv6XAirdsWos1983mLNs0g48y9?= =?us-ascii?Q?6XPFUFhi1XObVnlvVm=2F5FJqIK4+6hBJLQp2A4ZG?= =?us-ascii?Q?HXOISFy=2FWkCmqtfamBZfoJCOX25YQedlkmWuG08?= =?us-ascii?Q?uWkEVuEeyCPeiTg+SOWZ3izAr8VPHazJG5yKVFP?= =?us-ascii?Q?88RTm8LMzwRi6J5hOltftifUHpqEFhbB1qA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91919 Subject: [ruby-core:91919] [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 HarlemSquirrel (Kevin McCormack). As I'm reading through this I am warming up to this idea. However, I would prefer to keep `@` for instance variables. Ruby currently does not allow naming variables or methods starting with a number. Could we utilize this? ```ruby enumerable_object.map { 1a.method(2a) + 3a * 4a } ``` I might also suggest that the sequence start with `0a` since we have what feels like an "array" of parameters. ```ruby enumerable_object.map { "#{0a} comes before #{1a}" } ``` ---------------------------------------- Feature #4475: default variable name for parameter https://bugs.ruby-lang.org/issues/4475#change-77251 * Author: jordi (jordi polo) * Status: Closed * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * 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/