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/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>