Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dig(row,array_of_keys)
- return row if array_of_keys.count == 0
- current = case row
- when Hash
- current = row[array_of_keys.shift]
- when Array
- current = (row.find { |x| x.key?(key)} ||{})[key]
- else
- nil
- end
- dig(current, array_of_keys)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement