Project

General

Profile

Actions

Misc #17842

closed

Example incorrect in documentation for Hash#dig

Added by nickkelley (Nick Kelley) about 3 years ago. Updated about 3 years ago.


Description

In the current examples for Hash#dig, we have:

h = {foo: {bar: {baz: 2}}}
h.dig(:foo) # => {:bar=>{:baz=>2}}
h.dig(:foo, :bar) # => {:bar=>{:baz=>2}} <-- incorrect return value

This should be:

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

I have a pull request incoming to fix this on GitHub, but I can create a patch and post it here if that is better.

Documentation link for reference: https://ruby-doc.org/core-3.0.1/Hash.html#method-i-dig

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0