Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. def dig(row,array_of_keys)
  2. return row if array_of_keys.count == 0
  3. current = case row
  4. when Hash
  5. current = row[array_of_keys.shift]
  6. when Array
  7. current = (row.find { |x| x.key?(key)} ||{})[key]
  8. else
  9. nil
  10. end
  11.  
  12. dig(current, array_of_keys)
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement