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 7CB9E19C0008 for ; Wed, 7 Oct 2015 23:05:35 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id C23ABB5D886 for ; Wed, 7 Oct 2015 23:30:47 +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 8C96C952408 for ; Wed, 7 Oct 2015 23:30:47 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0D82F12065F; Wed, 7 Oct 2015 23:30:46 +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 2C6061205E3 for ; Wed, 7 Oct 2015 23:30:42 +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=e2DaHizr2mJp8APZTGdNrGvrZrw=; b=J40VlctD/jpcQ7vqoM /b2iyRv53Ja/R8MpJiS9D33H0X12ZFpA0EwiTFl/Vg6bxvPQ5xEUKYRCfC1KNFBA Xd3jkiB6m3oxrLp+IbpK6jOm3/46dSyzrJTtaOV97GB9d6zbTSvgXIN+hpvgbZV+ hDCuFAHg3sCd3zF3xuJ8tvRjU= Received: by filter0540p1mdw1.sendgrid.net with SMTP id filter0540p1mdw1.6159.56152C7E69 2015-10-07 14:30:22.939556301 +0000 UTC Received: from herokuapp.com (ec2-54-162-101-218.compute-1.amazonaws.com [54.162.101.218]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id Do6tIk6pRCy15rOPzPBLYg for ; Wed, 07 Oct 2015 14:30:23.219 +0000 (UTC) Date: Wed, 07 Oct 2015 14:30:23 +0000 From: matz@ruby-lang.org 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: 45629 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11537 X-Redmine-Issue-Author: hsbt 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5NPj4YE+OdU943l+yK2IprRDiOnubdSZQYIh ONqsFODngT8t7z5kL9eb6iJtuXom0byGJrAl9a9GRBH9ZVikqSxWjSRN0U84DeWV+lMc7xuy9jXyzK /XB6TK0g33KBrc/py/K6F7Ot7kAFzkwgsrXE X-ML-Name: ruby-core X-Mail-Count: 71012 Subject: [ruby-core:71012] [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 Yukihiro Matsumoto. I like the idea. My remaining concern is ".?" is too similar to "?." which is chosen by other languages. We cannot use "?." since it conflicts with a method call with a "*?" predicate method. Matz. ---------------------------------------- Feature #11537: Introduce "Safe navigation operator" https://bugs.ruby-lang.org/issues/11537#change-54387 * Author: Hiroshi SHIBATA * Status: Open * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I sometimes write following code with rails application: ```ruby u = User.find(id) if u && u.profile && u.profile.thumbnails && u.profiles.thumbnails.large ... ``` or ```ruby # 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: ```ruby u = User.find(id) u.?profile.?thumbnails.?large ``` Matz. How do you think about this? -- https://bugs.ruby-lang.org/