A simple macro to get deeply nested values in maps
Mar 1, 2016
I hate it when I have to write a lot of code to do simple things. Recently I
had to write some code to get a value in a deeply nested associative structure.
Consider the following example:
The immediately obvious solution is a pain:
However a smart clojurian quickly notices that he can use the awesome ->
macro to simplify things:
But that’s still way to long. Can we do better? Sure we can:
Now this is much better. Still I though I would write my own macro
just for the fun of it, so here you go:
Voila! A simple macro to make you code a bit nicer and avoid boilerplate.