Hi,
Been lurking here for a while (that is, via google), gotten a lot of help from people’s Q&As in the past, but I’ve gotten stuck on something that I don’t quite see an answer for in the documentation or the forums here. I feel like it’s something very simple, but I’m just not quite grokking how Access
works.
I know how to access stuff in nested maps, but my question is specifically about stuff structured like this:
[ %StructFromAListOfStructs{ a_list_nested_in_that_struct: [ %{ some_attribute: "Blah blah blah" } ] }, ... ]
Each map/struct in this list has an attribute which returns a list of maps, and I want to access the keys in those nested lists.
Now if this was simply a nested map, I’d know what to do, but I get confused at this point. I’m sure if I studied the docs a little harder I could figure it out, but I figured I’d leverage the expertise here and hopefully save myself some time (thanks in advance!).
What I normally do in these sorts of situations is Enum.flat_map
the list and then pipe into an Enum.map
to access the attribute. But that’s two loops round what is (in my case) some very long lists. Is there a more efficient way to do this?
(BTW, this is not struct specific, just used that for convenience of self-commenting my example.)