Slight update to Void
, a CLJC library for handling nil
(especially with collections): https://github.com/helins/void.cljc
(= (void/assoc {:a 42}
:a nil
:b 42)
{:a 42
:b 42})
this is surprising, I would expect {:b 42}
instead, in a way consistent with your update function.I had the same thought @vincent.cantin; Seems inconsistent with respect to whether nil clears out a k/v pair or just doesn't update.
cc @adam678
Indeed, assoc
is a no-op in case of nil. What you describe is its sibling, assoc-strict
, which does that :)
I guess it should be better examplified in the README.