Project

General

Profile

Actions

Feature #14548

open

Allow some_array&.[1] to be a valid syntax

Added by rosenfeld (Rodrigo Rosenfeld Rosas) over 6 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:85784]

Description

Currently, Ruby allows accessing an array's index while testing whether the array is not nil with this syntax: my_array&.[](1). I've always found this awkward but didn't mind about suggesting anything to improve this.

I was just reading about how JavaScript is probably going to support myArray?.[1] and found that it read good enough for me.

So I'd like to propose about the same syntax, replacing ?. with the Ruby equivalent &. instead. How does that look like to you?

Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0Like0