From: alissonbruno.sa@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91028] [Ruby trunk Feature#15526] New way to destruct an object hash
Date: Fri, 11 Jan 2019 19:45:17 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-15526.20190111194516.63e34ac8171be8de@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15526.20190111194516@ruby-lang.org
Issue #15526 has been reported by alissonbruno.sa (Alisson Santos).
----------------------------------------
Feature #15526: New way to destruct an object hash
https://bugs.ruby-lang.org/issues/15526
* Author: alissonbruno.sa (Alisson Santos)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
JavaScript has a nice a neat way to destruct objects.
~~~ javascript
const person = { name: "John Doe", age: 33 };
const { name, age } = person;
~~~
Erlang has a similar way to destruct a tuple:
~~~ erlang
Person = {"John Doe", 33}
{Name, Age} = Person
~~~
I think it's very handy and would be nice if we have something similar in Ruby.
~~~ ruby
config = { host: 'localhost', port: 3000 }
{ host, port } = config
~~~
I know Ruby has Hash#values_at, but I think this way it's more readable and understandable
What do you guys think?
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2019-01-11 19:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15526.20190111194516@ruby-lang.org>
2019-01-11 19:45 ` alissonbruno.sa [this message]
2019-01-11 19:57 ` [ruby-core:91030] [Ruby trunk Feature#15526] New way to destruct an object hash zverok.offline
2019-01-11 20:15 ` [ruby-core:91031] " shevegen
2019-01-11 20:35 ` [ruby-core:91032] " zverok.offline
2019-01-12 15:05 ` [ruby-core:91047] " janfri26
2019-01-14 15:45 ` [ruby-core:91083] " elia
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.issue-15526.20190111194516.63e34ac8171be8de@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).