From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7DB9B1F453 for ; Tue, 6 Nov 2018 14:33:23 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 64C3A12174E; Tue, 6 Nov 2018 23:33:20 +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 56B4C121739 for ; Tue, 6 Nov 2018 23:33:17 +0900 (JST) Received: by filter0182p3mdw1.sendgrid.net with SMTP id filter0182p3mdw1-11772-5BE1A62A-31 2018-11-06 14:33:14.563017999 +0000 UTC m=+490204.089823597 Received: from herokuapp.com (ec2-54-92-173-251.compute-1.amazonaws.com [54.92.173.251]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id Tz0W3n4SQ4ypm0rP988IZA Tue, 06 Nov 2018 14:33:14.462 +0000 (UTC) Date: Tue, 06 Nov 2018 14:33:14 +0000 (UTC) From: hanmac@gmx.de To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 65109 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 4475 X-Redmine-Issue-Author: jordi X-Redmine-Issue-Assignee: matz X-Redmine-Sender: Hanmac 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4BcYbbRlRKxUYjset8rsZ0KnkqalhNzg79Jj 8+1IeLozkluuzc2VU5TYdA7Y7uxPmzpI5NxccazhkxCA9critCgIg3dN+qrXGzwjjizXB95X1hAKvq 31DqkJLpl8dB2kxD8TDDeuETvhT5Nyy94wC9 X-ML-Name: ruby-core X-Mail-Count: 89724 Subject: [ruby-core:89724] [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 Hanmac (Hans Mackowiak). shevegen (Robert A. Heiler) wrote: > The first variant, aka the variant with "x", or any other single letter, including > "_", is something I use A LOT, and the reason is actually because it is shorter and > simpler to type for me. "_" is special there. it doesn't cause Syntax Error like you can do this `iterator.each {|a, _, c, _] }` but `iterator.each {|a, x, c, x] }` does crash ---------------------------------------- Feature #4475: default variable name for parameter https://bugs.ruby-lang.org/issues/4475#change-74767 * 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/