diff options
author | Bruno Facca <bruno@facca.info> | 2016-10-20 15:38:49 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-20 15:38:49 -0200 |
commit | 85dd85fe01a44a40a0363c6382382c35505522e0 (patch) | |
tree | f546f8bbed4b75dfc2a9c25996803b7ba3e5ce2f /guides/source | |
parent | 5741e87eea0b513aa2ec150507b973d0cef27ad4 (diff) | |
download | rails-85dd85fe01a44a40a0363c6382382c35505522e0.tar.gz rails-85dd85fe01a44a40a0363c6382382c35505522e0.tar.bz2 rails-85dd85fe01a44a40a0363c6382382c35505522e0.zip |
[ci skip] Fix return values of Hash Extensions examples
The hashes returned in some examples of the following sections had items in a different order than their receivers. That may mislead readers into believing those methods will not preserve element order.
Extensions to Hash/Working with Keys/transform_keys and transform_keys!
Extensions to Hash/Working with Keys/stringify_keys and stringify_keys!
Extensions to Hash/Working with Keys/symbolize_keys and symbolize_keys!
Extensions to Hash/Slicing
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 60a6c37f82..70b04a9695 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -2661,7 +2661,7 @@ The method `transform_keys` accepts a block and returns a hash that has applied ```ruby {nil => nil, 1 => 1, a: :a}.transform_keys { |key| key.to_s.upcase } -# => {"" => nil, "A" => :a, "1" => 1} +# => {"" => 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: @@ -2703,7 +2703,7 @@ The method `stringify_keys` returns a hash that has a stringified version of the ```ruby {nil => nil, 1 => 1, a: :a}.stringify_keys -# => {"" => nil, "a" => :a, "1" => 1} +# => {"" => 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: @@ -2745,7 +2745,7 @@ The method `symbolize_keys` returns a hash that has a symbolized version of the ```ruby {nil => nil, 1 => 1, "a" => "a"}.symbolize_keys -# => {1=>1, nil=>nil, :a=>"a"} +# => {nil=>nil, 1=>1, :a=>"a"} ``` WARNING. Note in the previous example only one key was symbolized. @@ -2822,7 +2822,7 @@ Ruby has built-in support for taking slices out of strings and arrays. Active Su ```ruby {a: 1, b: 2, c: 3}.slice(:a, :c) -# => {:c=>3, :a=>1} +# => {:a=>1, :c=>3} {a: 1, b: 2, c: 3}.slice(:b, :X) # => {:b=>2} # non-existing keys are ignored |