From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:81634] [Ruby trunk Feature#13645] Syntactic sugar for indexing when using the safe navigation operator
Date: Fri, 09 Jun 2017 09:52:41 +0000 [thread overview]
Message-ID: <redmine.journal-65330.20170609095241.2c827dc89ed33158@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13645.20170609073704@ruby-lang.org
Issue #13645 has been updated by shevegen (Robert A. Heiler).
Is this valid syntax? I ask specifically because of the '.' character there. I am not
a big fan of the & anyway though, so I am biased. I am just wondering in context of
syntax such as:
hash[:key]
hash&[:key]
hash&.[:key]
Actually I only consider the first elegant, the rest ugly. But I see your point
in regards to hash&.[](:key) versus hash&.[:key] - if the former already works
as-is, then it may make sense to allow for the latter. What I thought was that
the '.' is explicit for the method call; I guess the last example:
hash&.[:key]
Would then be equivalent to:
hash&.[(:key)]
right?
----------------------------------------
Feature #13645: Syntactic sugar for indexing when using the safe navigation operator
https://bugs.ruby-lang.org/issues/13645#change-65330
* Author: ndn (Nikola Nenkov)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
# Proposal
While it works and makes sense, this is a bit cumbersome:
```ruby
hash&.[](:key)
```
Ideally, we could use something like:
```ruby
hash&.[:key]
```
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2017-06-09 9:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-13645.20170609073704@ruby-lang.org>
2017-06-09 7:37 ` [ruby-core:81629] [Ruby trunk Feature#13645] Syntactic sugar for indexing when using the safe navigation operator ndnenkov
2017-06-09 9:52 ` shevegen [this message]
2017-06-09 10:13 ` [ruby-core:81636] " sawadatsuyoshi
2019-04-16 15:01 ` [ruby-core:92305] " manga.osyo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-65330.20170609095241.2c827dc89ed33158@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).