One liner to fetch the value from hash in Ruby.

shilpi230 profile image Shilpi Agrawal ・1 min read

Struggling with fetching values from nested hash and looking for one liner, to get the work done.
Here, is something really fun I have found. Have a look at it.

Alt Text

Have fun using it. And don't forget to drop some love and comment.


markdown guide

Pro Tip:
Use safe navigation to handle nil case

cat&.dig(:breed, :persian_cat, :name)

Thanks! Rahul, thats helpful.