Answers for "dig method in ruby How to check whether a nested hash element exists"

0

dig method in ruby How to check whether a nested hash element exists

class Hash
  def dig(*path)
    path.inject(self) do |location, key|
      location.respond_to?(:keys) ? location[key] : nil
    end
  end
end
Posted by: Guest on June-20-2021

Code answers related to "dig method in ruby How to check whether a nested hash element exists"

Browse Popular Code Answers by Language