[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>

Currently, ruby/spec is maintained mostly by individuals and enjoys the

13 messages 2016/12/13

[ruby-core:78705] [Ruby trunk Feature#13045] Passing a Hash with String keys as keyword arguments

From: chertoly@...
Date: 2016-12-17 12:20:02 UTC
List: ruby-core #78705
Issue #13045 has been updated by Anatoly Chernow.


Nobuyoshi Nakada wrote:
> I'm not a fun for this idea, since `Symbol` and `String` are different.

They are different. However, sometimes they are treated as the same(for example, when passed as a method name to `BasicObject#send`).

Hashes with string keys are ubiquitous. Should this idea be accepted, processing them would become a lot simpler.

(Thank you for your corrections of my initial message.)

----------------------------------------
Feature #13045: Passing a Hash with String keys as keyword arguments
https://bugs.ruby-lang.org/issues/13045#change-62081

* Author: Anatoly Chernow
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
To the following method

~~~ ruby
def new request:, response:
end
~~~
I'd like to be able to pass both

~~~ ruby
hash_with_symbol_keys = { request: another_hash, response: another_hash2 }
hash_with_string_keys = { 'request' => another_hash, 'response' => another_hash2 }
~~~

I would make a lot cleaner parsing many things returned with string keys(like the output of `YAML.load`).

If you don't like the above feature, could you please at least consider adding `Hash#symbolize_keys`(like you did with `Hash#transform_values`)?



-- 
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>

In This Thread

Prev Next