I have struct map like this
(def admin (struct-map person :first-name "Name" :last-name "Last name"))
So, now I would like to add new key-value pair to this map, and have it look something like
(def admin (struct-map person :first-name "Name" :last-name "Last name" :username "username"))
How do I do this?
I know that it won't be the same structure after this, but it doesn't matter.
If you are not concerned with retaining the structure, assoc
will add your new key-value pair.
(defstruct person :first-name :last-name)
(def admin (struct-map person
:first-name "Name"
:last-name "Last name"))
(assoc admin :username "username")
;=> {:first-name "Name", :last-name "Last name", :username "username"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With