v2_4_6 - Show latest stable - 0 notes - Class: Struct
dig(*args) public

Extracts the nested value specified by the sequence of key objects by calling dig at each step, returning nil if any intermediate step is nil.

Foo =
f ={b: [1, 2, 3]}))

f.dig(:a, :a, :b, 0)    # => 1
f.dig(:b, 0)            # => nil
f.dig(:a, :a, :b, :c)   # TypeError: no implicit conversion of Symbol into Integer
Show source
Register or log in to add new notes.