Today I Learned

A Hashrocket project

ruby has get-in, but it's called dig!

Ever miss that sweet functional language feature when you’re in ruby?

(get-in {:a [{:b 2}]} [:a 0 :b])
=> 2

docs

Well, if you’re on ruby >= 2.3, you can!

{a: [b: 2]}.dig(:a, 0, :b)
=> 2

docs

Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.