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.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, 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 669E81F453 for ; Fri, 2 Nov 2018 20:55:26 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D04DA1214C4; Sat, 3 Nov 2018 05:55:24 +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 9CC291214C3 for ; Sat, 3 Nov 2018 05:55:22 +0900 (JST) Received: by filter0193p3mdw1.sendgrid.net with SMTP id filter0193p3mdw1-9514-5BDCB9B7-29 2018-11-02 20:55:19.741391079 +0000 UTC m=+167056.286072913 Received: from herokuapp.com (ec2-54-167-242-137.compute-1.amazonaws.com [54.167.242.137]) by ismtpd0012p1iad2.sendgrid.net (SG) with ESMTP id F1sgpcYbSUmGCJtYHyt23Q for ; Fri, 02 Nov 2018 20:55:19.791 +0000 (UTC) Date: Fri, 02 Nov 2018 20:55:20 +0000 (UTC) From: manga.osyo@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 65069 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15236 X-Redmine-Issue-Author: ignatiusreza X-Redmine-Sender: osyo 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS7+jx9dVpZRp92LukFdIUKqB/DlRHTH6a+vzT rW/yf4r7i5twe1OnuceIXiyOfLMin9BdtIvcw2SM7MPrLs1d3o8IG7Q0NWy4n1AOFNR4yYrG6ktuw2 ANiW53LsWEC+zPgQ1v6AFlNdFJdxX4NDin8Nz629tM9RSkfXNtoeAQuhbQ== X-ML-Name: ruby-core X-Mail-Count: 89684 Subject: [ruby-core:89684] [Ruby trunk Feature#15236] add support for hash shorthand 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 #15236 has been updated by osyo (manga osyo). I would like to use Hash shorthand in the following cases. ``` describe User do let(:id) { ... } let(:name) { ... } let(:age) { ... } let(:registered_at) { ... } # I want to hash shorthand! let(:user) { User.new(id: id, age: age, name: name, registered_at: registered_at) } context '`name` is nil' do let(:name) { nil } it { ... } end context '`age` is nil' do let(:age) { nil } it { ... } end end ``` ---------------------------------------- Feature #15236: add support for hash shorthand https://bugs.ruby-lang.org/issues/15236#change-74724 * Author: ignatiusreza (Ignatius Reza Lesmana) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- PR in github: https://github.com/ruby/ruby/pull/1990 inspired by javascript support for object literal shorthand notation `{ a }`, which will be expanded into `{ a: a }`.. to avoid ambiguity, this shorthand is only supported when hash is defined with `{ }` notation.. in other situation where the brackets is optional, e.g. function call, we still need to write it in full (`m(a : a)` instead of `m(a)`, or `m(a, b, c: c)` instead of `m(a, b, c)`.. -- https://bugs.ruby-lang.org/