module Diggable

Extend any class or object that implements a [] method, to also have dig

Public Instance Methods

dig(*idx) click to toggle source

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

# File lib/mug/diggable.rb, line 12
def dig *idx
  inner = self[idx.shift]
  return inner if idx.empty? || inner.nil?
  inner.dig(*idx)
end