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 303AF19A0AD1 for ; Fri, 18 Sep 2015 18:08:44 +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 00429B5D8B8 for ; Fri, 18 Sep 2015 18:31:27 +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 30B0297A82C for ; Fri, 18 Sep 2015 18:31:29 +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 12F07952408 for ; Fri, 18 Sep 2015 18:31:26 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E0E8612075F; Fri, 18 Sep 2015 18:31:26 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from mail-ig0-f180.google.com (mail-ig0-f180.google.com [209.85.213.180]) by neon.ruby-lang.org (Postfix) with ESMTPS id 803151205F8 for ; Fri, 18 Sep 2015 18:31:22 +0900 (JST) Received: by igxx6 with SMTP id x6so13501012igx.1 for ; Fri, 18 Sep 2015 02:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=CuIiGFBqrGPjEBB5w2S3OyuYUqF8WFPAdQFZjKPPJb8=; b=cE7d6CGVlZ4ms0aH4/mMRGPZ9ZWxZbpNRcu/9HYPec4p0tPgz3lD4Unx9slGnYvUb2 231I9SVBC/CukaCaJ3FHt0rNRuJe+T/RfPgwDodw5HOMar2kVu437TppzDwwYqxpGIK0 J013WSAFzCasnjz+y/0FOiE6FCSfjuI1NUif5xN9ytsdOBVXQYr4wOzpz6HPj/SD8ghL ywz81rQbWNwGlJ9LBR/aAW59SO8s7rHxyjRHTbeCQyUTm6YQyEmhghNh5dgT6kfZkwFX 9mGwceqmHMgOk70GDrvsfnB1iIZr8RydLZdgeMy8ijHyvsM6kpXOOfrzJGZK4/TqXdk/ qXKQ== MIME-Version: 1.0 X-Received: by 10.50.136.231 with SMTP id qd7mr13291068igb.11.1442568680798; Fri, 18 Sep 2015 02:31:20 -0700 (PDT) Received: by 10.107.12.221 with HTTP; Fri, 18 Sep 2015 02:31:20 -0700 (PDT) In-Reply-To: References: Date: Fri, 18 Sep 2015 17:31:20 +0800 Message-ID: From: "P.S.V.R" To: Ruby developers Content-Type: multipart/alternative; boundary=089e0122aa5ac8831205200231a5 X-ML-Name: ruby-core X-Mail-Count: 70855 Subject: [ruby-core:70855] Re: [Ruby trunk - Feature #11537] [Open] 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" --089e0122aa5ac8831205200231a5 Content-Type: text/plain; charset=UTF-8 +1 On Fri, Sep 18, 2015 at 5:29 PM, wrote: > Issue #11537 has been reported by Hiroshi SHIBATA. > > ---------------------------------------- > Feature #11537: Introduce "Safe navigation operator" > https://bugs.ruby-lang.org/issues/11537 > > * 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/ > -- https://github.com/pmq20 --089e0122aa5ac8831205200231a5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
+1

On Fri, Sep 18, 2015 at 5:29 PM, <shibata.hiroshi@gmail.c= om> wrote:
Issue #11537 has= been reported by Hiroshi SHIBATA.

----------------------------------------
Feature #11537: Introduce "Safe navigation operator"
https://bugs.ruby-lang.org/issues/11537

* Author: Hiroshi SHIBATA
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
I somtimes write following code with rails application:

```rb
u =3D User.find(id)
if u && u.profile && u.profile.thumbnails && u.prof= iles.thumbnails.large
=C2=A0 ...
```

or

```rb
# Use ActiveSupport
if u.try!(:profile).try!(:thumbnails).try!(:large)
=C2=A0...
```
I hope to write shortly above code. Groovy has above operator named "S= afe navigation operator" with "?." syntax.
Ruby can't use "?." operator.

Can we use ".?" syntax. like this:

```rb
u =3D User.find(id)
u.?profile.?thumbnails.?large
```

Matz. How do you think about this?




--
https://bugs.ruby-lang.org/



--
--089e0122aa5ac8831205200231a5--