Closed drusellers closed 8 years ago
^:displace
is the opposite of ^:replace
. With replace, the map to the right takes precedence, while with displace the map to the left takes precedence.
A good use for ^:displace
to create defaults. Essentially you're marking a value to be overridden, to have the lowest priority.
ok, so using that in the repl now I can see. Would you be ok if I added this to the README.md via a PR?
(meta-merge {:a [:b :c] :b [1 2]} {:a ^:displace [:d]})
=> {:a [:b :c] :b [1 2]}
(meta-merge {:b [1 2]} {:a ^:displace [:d]})
=> {:a [:d] :b [1 2]}
Looking at the readme I'm not clear what
^:displace
is doing.I tried at the repl
But that didn't do anything either. I also looked at the tests for displace but its the same example and looking at the code I can see it has to do with priority but its not clear to my dense block head exactly what is going down.
thank you in advance.