Actions
Feature #14548
closedAllow some_array&.[1] to be a valid syntax
Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
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?
Updated by nobu (Nobuyoshi Nakada) about 4 years ago
Updated by matz (Yukihiro Matsumoto) almost 3 years ago
- Status changed from Open to Rejected
And it's too confusing. ary&.[]
and ary&.[]()
for example.
Updated by hsbt (Hiroshi SHIBATA) 5 months ago
- Project changed from 14 to Ruby master
Actions