How to make a record from a sequence of values

后端 未结 5 1314
执笔经年
执笔经年 2020-12-20 13:38

I have a simple record definition, for example

(defrecord User [name email place])

What is the best way to make a record having it\'s value

5条回答
  •  心在旅途
    2020-12-20 14:03

    One simple thing you can do is to make use of destructuring.

    (defn make-user [[name email place]]
      (User. name email place))
    

    Then you can just call it like this

    (make-user ["John" "John@example.com" "Dreamland"])
    

提交回复
热议问题