Skip to content

Instantly share code, notes, and snippets.

@getnashty
Created June 13, 2013 16:16
Show Gist options
  • Save getnashty/5775048 to your computer and use it in GitHub Desktop.
Save getnashty/5775048 to your computer and use it in GitHub Desktop.
def nested_hash_value(obj,key)
if obj.respond_to?(:key?) && obj.key?(key)
obj[key]
elsif obj.respond_to?(:each)
r = nil
obj.find{ |*a| r=nested_hash_value(a.last,key) }
r
end
end
@treasonx
Copy link

Should be something like

function findPlacement(obj) {
  if(obj.placement != null) {
    //yay placement
  }
  if(obj.sections) {
      obj.sections.forEach(findPlacement);  
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment