Correct documentation example on Hash#dig

Fixes [Misc #17842]. The current documentation suggests that:

        {foo: {bar: {baz: 2}}}.dig(:foo, :bar) # => {:bar=>{:baz=>2}}

when it should be:

        {foo: {bar: {baz: 2}}}.dig(:foo, :bar) # => {:baz=>2}
This commit is contained in:
Nick Kelley 2021-04-30 15:12:34 -07:00 committed by Jeremy Evans
parent 1f255adda9
commit a9824a3113
Notes: git 2021-05-01 07:46:46 +09:00

2
hash.c
View File

@ -4555,7 +4555,7 @@ rb_hash_any_p(int argc, VALUE *argv, VALUE hash)
* Nested Hashes:
* h = {foo: {bar: {baz: 2}}}
* h.dig(:foo) # => {:bar=>{:baz=>2}}
* h.dig(:foo, :bar) # => {:bar=>{:baz=>2}}
* h.dig(:foo, :bar) # => {:baz=>2}
* h.dig(:foo, :bar, :baz) # => 2
* h.dig(:foo, :bar, :BAZ) # => nil
*