Project

General

Profile

Actions

Feature #14579

closed

Hash value omission

Added by shugo (Shugo Maeda) over 6 years ago. Updated about 1 year ago.

Status:
Closed
Target version:
-
[ruby-core:85950]

Description

How about to allow value omission in Hash literals:

x = 1
y = 2
h = {x:, y:}
p h #=> {:x=>1, :y=>2}

And in keyword arguments:

def login(username: ENV["USER"], password:)
  p(username:, password:)
end

login(password: "xxx") #=> {:username=>"shugo", :password=>"xxx"}

Files

hash_value_omission.diff (619 Bytes) hash_value_omission.diff shugo (Shugo Maeda), 03/06/2018 01:51 PM

Related issues 4 (0 open4 closed)

Related to Ruby master - Feature #11105: ES6-like hash literalsRejectedActions
Related to Ruby master - Feature #18124: Hash shorthands (matching constructors functionality in JS)ClosedActions
Related to Ruby master - Feature #14973: Proposal of percent literal to expand HashClosedActions
Has duplicate Ruby master - Feature #17292: Hash Shorthand / PunningClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like1Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0