From: "Dan0042 (Daniel DeLorme)" Date: 2021-09-16T01:41:23+00:00 Subject: [ruby-core:105274] [Ruby master Feature#14579] Hash value omission Issue #14579 has been updated by Dan0042 (Daniel DeLorme). matz (Yukihiro Matsumoto) wrote in #note-16: > I assumed the value should be a local variable. I also assumed the same thing, but after getting over my initial surprise I found this way is quite nice, very ruby-ish. A bit like learning that `rescue => obj.attr` is valid. ---------------------------------------- Feature #14579: Hash value omission https://bugs.ruby-lang.org/issues/14579#change-93685 * Author: shugo (Shugo Maeda) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- 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: