From: shugo@... Date: 2018-03-09T08:59:47+00:00 Subject: [ruby-core:86065] [Ruby trunk Feature#14579] Hash value omission Issue #14579 has been updated by shugo (Shugo Maeda). Eregon (Benoit Daloze) wrote: > I'd prefer a syntax which is different than "key syntax without value", and refers to the variable name used for the value more clearly, like: > > ~~~ruby > x = 1 > y = 2 > h = {x, y} > ~~~ I proposed the above syntax in #11105, but it was rejected, and this proposal is alternative. ---------------------------------------- Feature #14579: Hash value omission https://bugs.ruby-lang.org/issues/14579#change-70930 * Author: shugo (Shugo Maeda) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- How about to allow value omission in Hash literals: ```ruby x = 1 y = 2 h = {x:, y:} p h #=> {:x=>1, :y=>2} ``` And in keyword arguments: ```ruby def login(username: ENV["USER"], password:) p(username:, password:) end login(password: "xxx") #=> {:username=>"shugo", :password=>"xxx"} ``` ---Files-------------------------------- hash_value_omission.diff (619 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: