提交 b064a781 编写于 作者: R Ryuta Kamizono

Merge pull request #36348 from corprew/docs-stringify-keys-stable-result

[documentation][ci skip] stringify_keys and symbolize_keys have stable results.
上级 728e8ed9
......@@ -2633,14 +2633,12 @@ The method `stringify_keys` returns a hash that has a stringified version of the
# => {"" => nil, "1" => 1, "a" => :a}
```
In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
In case of key collision, the value will be the one most recently inserted into the hash:
```ruby
{"a" => 1, a: 2}.stringify_keys
# The result could either be
# The result will be
# => {"a"=>2}
# or
# => {"a"=>1}
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionView::Helpers::FormHelper` defines:
......@@ -2677,14 +2675,12 @@ The method `symbolize_keys` returns a hash that has a symbolized version of the
WARNING. Note in the previous example only one key was symbolized.
In case of key collision, one of the values will be chosen. The chosen value may not always be the same given the same hash:
In case of key collision, the value will be the one most recently inserted into the hash:
```ruby
{"a" => 1, a: 2}.symbolize_keys
# The result could either be
# The result will be
# => {:a=>2}
# or
# => {:a=>1}
```
This method may be useful for example to easily accept both symbols and strings as options. For instance `ActionController::UrlRewriter` defines
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册