Feature #9853

Please consider quoted generation of hash like in %h( foo bar bee blaa )

Added by Robert A. Heiler over 1 year ago.

[ruby-core:62678]
Status:Open
Priority:Normal
Assignee:-

Description

Hi.

In Ruby we can do this:

%w( foo bar bee blaa ) # => ["foo", "bar", "bee", "blaa"]

Ok makes an array of strings.

We can do this:

%i( foo bar bee blaa ) # => [:foo, :bar, :bee, :blaa]

Ok, makes an array of symbols.

We can also use [] on class Hash to generate a hash:

Hash[*%w( foo bar bee blaa )] # => {"foo"=>"bar", "bee"=>"blaa"}

My question:

Would it be possible to add %h() ? It would create a hash:

%h( foo bar bee blaa ) # => {"foo"=>"bar", "bee"=>"blaa"}

And would raise if odd number of arguments would be supplied.

Also available in: Atom PDF