Issue #11813 has been updated by Nobuyoshi Nakada.


Usaku NAKAMURA wrote:
> IMO, we can write `&.` only for replacement of `.`.
> As you know, `ary.[idx]` is not valid, then `ary&.[idx]` should not be valid, too.

That is same as matz's opinion and the reason it was removed at r52430.

    parse.y: revert lbracket
    
    * parse.y (lbracket): remove .? before aref.  [Feature #11537]
      revert r52422 and r52424

I don't think this proposal will be accepted.
We'll need a better notation.

----------------------------------------
Feature #11813: Extend safe navigation operator for [] and []= with syntax sugar
https://bugs.ruby-lang.org/issues/11813#change-55518

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
Now we have the safe navigation operator `&.`. But this cannot be used with syntax sugar form of the methods `[]` and `[]=`, which are more frequent than their ordinary forms of method call. For example, when `a` can be either an array or `nil`, we can do:

    a &.[](3)
    a &.[]= 2, :foo

but we cannot do:

    a &.[3]
    a &.[2] = :foo

It would be nice if we can extend the use of `&.` to cover syntactic sugar as above.



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