DEV Community

Discussion on: One liner to fetch the value from hash in Ruby.

Collapse
 
rahul_ramfort profile image
Rahul

Pro Tip:
Use safe navigation to handle nil case

cat&.dig(:breed, :persian_cat, :name)
Collapse
 
shilpi230 profile image
Shilpi Agrawal

Thanks! Rahul, thats helpful.