Issue #14579 has been updated by shevegen (Robert A. Heiler).


I agree with Matthew.

I understand the suggestion trying to make the syntax even more succinct
but I think it's one step too much. Ruby already has a quite condensed
syntax.

I think this syntax here:

    h = { "x" => , "y" => }

Has a slight "visual" problem, at the least to me. I would expect =>
to "point" to something on the right hand side, which the normal
syntax in hashes, in ruby, requires (unless you use the foo: :bar
syntax notation).

----------------------------------------
Feature #14579: Hash value omission
https://bugs.ruby-lang.org/issues/14579#change-70928

* 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: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>