For example, if I had:
(defrecord Item [name cost])
How could I convert ["ball" 10] to {:name "ball", :cost 10}?
user=> (defrecord Item [name cost])
user=> (apply ->Item ["ball" 10])
#user.Item{:name "ball", :cost 10}
Short explain of what's going on. (->Item "ball" 10) is one of syntax for creating record from given arguments. It's the same as (Item. "ball" 10). In your case you have vector of arguments, so we use (apply fn args-vector) to deal with.
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