Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dig #method #ruby #How #check #nested #hash #element #exists
ADD COMMENT
Topic
Name
7+9 =