From: "rosenfeld (Rodrigo Rosenfeld Rosas)" Date: 2012-07-01T22:21:44+09:00 Subject: [ruby-core:46054] [ruby-trunk - Feature #6414] Destructuring Assignment Issue #6414 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). -1. I'd still like to see Ruby supporting CoffeeScript hash style for this common pattern: Instead of a = 1; b = 2; c = {a: a, b: b} I'd prefer to write just c = {a, b}. The current proposed syntax wouldn't allow such a feature in the future.... :( By the way, I can't remember what is the current situation of an old proposition to allow things like {"#{interpolation}": value} as well as {'some string': value}. Was it already accepted? Is there already a slide for it? ---------------------------------------- Feature #6414: Destructuring Assignment https://bugs.ruby-lang.org/issues/6414#change-27661 Author: edtsech (Edward Tsech) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: core Target version: 2.0.0 I mean: john = {name: "John", last: "Smith"} {name, last} = john # extract value by key from the hash and set to local variable with same name name # => "John" last # -> "Smith" Useful for ex. for "options" hashes: def select(options={}) {only, except} = options ... end As extra part of this feature can be hash constructing in this way: name = "John" last = "Smith" find({name, last}) # equals to => find({name: "John", last: "Smith"}) I think both really nice to have in Ruby. Thanks. -- http://bugs.ruby-lang.org/