From: duerst Date: 2021-09-15T09:27:42+00:00 Subject: [ruby-core:105264] [Ruby master Feature#14579] Hash value omission Issue #14579 has been updated by duerst (Martin D�rst). shugo (Shugo Maeda) wrote in #note-26: > duerst (Martin D�rst) wrote in #note-25: > Technically speaking, `send(:if)` is used instead of local_variable_get if the local variable is not defined. > > > Not sure we need this, but also not sure it hurts. > > In the meeting just after RubyKaigi, someone pointed out that `{if:}[:if]` is faster than `binding.local_variable_get(:if)`. I don't think using `if` as the name of a local variable is a good idea, and I don't think the speed of bad ideas should concern us too much. ---------------------------------------- Feature #14579: Hash value omission https://bugs.ruby-lang.org/issues/14579#change-93674 * 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: