aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-05-28 17:13:28 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-05-28 17:14:19 +0900
commit93e640735e9363672b770b8d1c5a35f9e464f806 (patch)
tree283c7a85645c2bc67e3836134fe637f4a0b8ba68 /guides/source
parent5b5c6c133a6c88576d264afd34222efceaa6ec9e (diff)
parent82ee7a0fa93e6f9ec69804734c8981217587dae5 (diff)
downloadrails-93e640735e9363672b770b8d1c5a35f9e464f806.tar.gz
rails-93e640735e9363672b770b8d1c5a35f9e464f806.tar.bz2
rails-93e640735e9363672b770b8d1c5a35f9e464f806.zip
Merge pull request #36348 from corprew/docs-stringify-keys-stable-result
[documentation][ci skip] stringify_keys and symbolize_keys have stable results.
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/active_support_core_extensions.md12
1 files changed, 4 insertions, 8 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 1a057832d4..21901a7158 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -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