Actions
Feature #13137
closedHash Shorthand
Feature #13137:
Hash Shorthand
Status:
Rejected
Assignee:
-
Target version:
-
Description
The ES6 update to Javascript added object shorthand. I propose that a similar hash shorthand be added to Ruby.
Before¶
name = 'Matz'
country = 'Japan'
attributes = {
name: name,
country: country
}
After¶
name = 'Matz'
country = 'Japan'
attributes = {
name,
country
}
This would be very useful when building hashes from keyword arguments (especially with default values):
def build(name: 'John Doe', age: 100, country: 'Earth', )
attributes = {
name,
age,
country
}
end
Actions