module RubyDig
  def dig(key, *other_keys)
    if value = self[key] rescue nil
      if other_keys.empty?
        value
      elsif value.is_a?(RubyDig)
        other_key, *rest = other_keys
        value.dig(other_key, *rest)
      end
    end
  end
end

class Array
  include RubyDig
end

class Hash
  include RubyDig
end

module RubyDig
  def dig(key, *rest)
    if value = (self[key] rescue nil)
      if rest.empty?
        value
      elsif value.is_a?(RubyDig)
        value.dig(*rest)
      end
    end
  end
end

class Array
  include RubyDig
end

class Hash
  include RubyDig
end

Use splat inline and add parens for clarity
Use splat inline and add parens for clarity
