Skip to content

Commit 73b2c8d

Browse files
committed
📝 Introduce Hash#dig and link to more info
1 parent 95b8ea4 commit 73b2c8d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ Comparison:
575575

576576
##### `Hash#dig` vs `Hash#[]` vs `Hash#fetch` [code](code/hash/dig-vs-[]-fetch.rb)
577577

578+
[Ruby 2.3 introduced `Hash#dig`](http://ruby-doc.org/core-2.3.0/Hash.html#method-i-dig) which is a readable
579+
and performant option for retrieval from a nested hash, returning `nil` if an extraction step fails.
580+
See https://github.com/JuanitoFatas/fast-ruby/pull/102#issuecomment-198827506 for more info.
581+
578582
```
579583
$ ruby -v code/hash/dig-vs-\[\]-vs-fetch.rb
580584
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

0 commit comments

Comments
 (0)