From: lyoneil.de.sire@... Date: 2019-06-09T03:11:16+00:00 Subject: [ruby-core:93030] [Ruby trunk Feature#15236] add support for hash shorthand Issue #15236 has been updated by ignatiusreza (Ignatius Reza Lesmana). I was reading the presentation slide for the experimental feature for syntax matching.. in which, there's support for "shorthand" matching with hash, in the form of `{ a: }`.. or, following the examples presented above: ``` def foo(param1:, param2:) param + param2 end param1 = 7 param2 = 42 foo(param1:, param2:) def respond_with(resource, options) meta = extract_meta(resource, options) etc = extract_etc(resource, options) { resource:, meta:, etc: } end # destructuring {data:, meta:, etc:} = {data: [1,2,3], meta: {mobile: true}, etc: "more info"} ``` I think, this answers the concern mentioned above regarding `{ a }` being confused with a Set instead of Hash.. wydt? ref: https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7?slide=34 ---------------------------------------- Feature #15236: add support for hash shorthand https://bugs.ruby-lang.org/issues/15236#change-78404 * Author: ignatiusreza (Ignatius Reza Lesmana) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- PR in github: https://github.com/ruby/ruby/pull/1990 inspired by javascript support for object literal shorthand notation `{ a }`, which will be expanded into `{ a: a }`.. to avoid ambiguity, this shorthand is only supported when hash is defined with `{ }` notation.. in other situation where the brackets is optional, e.g. function call, we still need to write it in full (`m(a : a)` instead of `m(a)`, or `m(a, b, c: c)` instead of `m(a, b, c)`.. -- https://bugs.ruby-lang.org/ Unsubscribe: