Skip to content

Instantly share code, notes, and snippets.

@mrb

mrb/nesteddata.rb

Created Sep 8, 2016
Embed
What would you like to do?
def format(result)
# The data I want is deeply nested in the "result" hash
results = result.first[1]["coverage"]
end
@akahn

This comment has been minimized.

Copy link

@akahn akahn commented Sep 8, 2016

if result
  if result.first
    if result.first[1]
       if result.first[1]["coverage"]
         result.first[1]["coverage"]
       end
     end
   end
end

OR

result.first[1]["coverage"] rescue nil

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