Issue #13137 has been updated by naruse (Yui NARUSE).


Note: such culture seems to come from SGML.

----------------------------------------
Feature #13137: Hash Shorthand
https://bugs.ruby-lang.org/issues/13137#change-64206

* Author: trevorlynnsmith (Trevor Smith)
* Status: Rejected
* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>