I am writing some and I need to pass a complicated data structure to some function.
The data structure goes like this:
{ 'animals': [ 'cows', 'moose', { 'properties': [ 9, 26 ] } ]
'fruits': {
'land': [ 'strawberries', 'other berries' ],
'space': [ 'apples', 'cherries' ]
}
}
This structure looks pretty ugly to me. Can you think of ways how to simplify writing such massive data structures?
PS. I made up this structure but my real structure is very similar tho.
Other languages would solve this problem with objects or structs– so, something like:
Of course, this only works if you know ahead of time what form the data is going to take. If you don’t, then maps/lists are your only choice 😉