From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 3225919A0AD1 for ; Fri, 18 Sep 2015 23:12:30 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 1EBB7B5D831 for ; Fri, 18 Sep 2015 23:35:14 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id DA1F197A826 for ; Fri, 18 Sep 2015 23:35:16 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id DFDA4952408 for ; Fri, 18 Sep 2015 23:35:13 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 454F012080F; Fri, 18 Sep 2015 23:35:12 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 4104B12080A for ; Fri, 18 Sep 2015 23:35:07 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=16wWzGfWbScPt+Trp8HGVvtSkLM=; b=JSkIU5Vi6Xs33pQpN3 1U2BWzy72Azx2JDzlQ1meRqiIVtJSAXf9zoa6jcw9rtAjrI5O6r16t0YgN4ny4kW 1/h9BAkPjHf7If4TZgsf0gsPf8eRaNbOWN35h4LYhx+Qpogzj1q1ROIiV/gXet12 e9xwZzE72lMnDpElw0mGRSWIw= Received: by filter0530p1mdw1.sendgrid.net with SMTP id filter0530p1mdw1.19045.55FC210C9 2015-09-18 14:34:52.051361768 +0000 UTC Received: from herokuapp.com (ec2-54-157-44-68.compute-1.amazonaws.com [54.157.44.68]) by ismtpd0006p1iad1.sendgrid.net (SG) with ESMTP id n1XwkjFWSsunl0iWwS-ZaA for ; Fri, 18 Sep 2015 14:34:52.588 +0000 (UTC) Date: Fri, 18 Sep 2015 14:34:52 +0000 From: rr.rosas@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45467 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11537 X-Redmine-Issue-Author: hsbt X-Redmine-Issue-Assignee: matz X-Redmine-Sender: rosenfeld 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS6QB0MEJzAVTADre9oO6N1RSDJqpItlnYr1+J T3n8R7Ls2BIErTldovtlqUIx0GaEuCQ6pxHrDH+ospH8UYUhc80Kt6DpHb6cBPHJAPyIgZlGc1KzMx pgGjKFJFW+4+uhi3zcYHStecBU4VwA/xQTr2 X-SendGrid-Contentd-ID: {"test_id":"1442586893"} X-ML-Name: ruby-core X-Mail-Count: 70856 Subject: [ruby-core:70856] [Ruby trunk - Feature #11537] Introduce "Safe navigation operator" 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11537 has been updated by Rodrigo Rosenfeld Rosas. +1. Besides Groovy, CoffeeScript also allows that and I've used this feature a lot in my past days with Groovy and still use it all the time with CoffeeScript and have been missing this feature in Ruby for a long time. ---------------------------------------- Feature #11537: Introduce "Safe navigation operator" https://bugs.ruby-lang.org/issues/11537#change-54236 * Author: Hiroshi SHIBATA * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I somtimes write following code with rails application: ```rb u = User.find(id) if u && u.profile && u.profile.thumbnails && u.profiles.thumbnails.large ... ``` or ```rb # Use ActiveSupport if u.try!(:profile).try!(:thumbnails).try!(:large) ... ``` I hope to write shortly above code. Groovy has above operator named "Safe navigation operator" with "?." syntax. Ruby can't use "?." operator. Can we use ".?" syntax. like this: ```rb u = User.find(id) u.?profile.?thumbnails.?large ``` Matz. How do you think about this? -- https://bugs.ruby-lang.org/