From: shevegen@... Date: 2017-01-20T01:27:01+00:00 Subject: [ruby-core:79169] [Ruby trunk Feature#13137] Hash Shorthand Issue #13137 has been updated by Robert A. Heiler. While I understand the primary reasoning behind it - less to type - I do not like the syntax proposal. To me it looks as if there is something missing in the build-up of the hash elements. It appears to put load onto my brain and appears to be inconsistent with how I would normally populate a hash with key-value pairs. Perhaps one day we could use some advanced hash that does all of these things including hash with indifferent syntax. But I think it would be better for core hash to stay the way it is without any new implicit syntax. To quote matz though, he wrote in the other thread that there may be a chance to revisit it in the future, e. g. when ES6 syntax may be more popular. ---------------------------------------- Feature #13137: Hash Shorthand https://bugs.ruby-lang.org/issues/13137#change-62592 * Author: Trevor Smith * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- The ES6 update to Javascript added object shorthand. I propose that a similar hash shorthand be added to Ruby. ### Before ~~~ ruby name = 'Matz' country = 'Japan' attributes = { name: name, country: country } ~~~ ### After ~~~ ruby name = 'Matz' country = 'Japan' attributes = { name, country } ~~~ This would be very useful when building hashes from keyword arguments (especially with default values): ~~~ ruby def build(name: 'John Doe', age: 100, country: 'Earth', ) attributes = { name, age, country } end ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: