Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # defrecord {{ https://i.imgur.com/170Q9gf.png }} {{ https://i.imgur.com/rVtRpC0.png }} {{ https://i.imgur.com/8t3EWxN.png }} <code clojure> ;; from Stu's examples: (defrecord Person [fname lname address]) -> user.Person (defrecord Address [street city state zip]) -> user.Address (def stu (Person. "Stu" "Halloway" (Address. "200 N Mangum" "Durham" "NC" 27701))) -> #'user/stu (:lname stu) -> "Halloway" (-> stu :address :city) -> "Durham" (assoc stu :fname "Stuart") -> #:user.Person{:fname "Stuart", :lname "Halloway", :address #:user.Address{:street "200 N Mangum", :city "Durham", :state "NC", :zip 27701}} (update-in stu [:address :zip] inc) -> #:user.Person{:fname "Stu", :lname "Halloway", :address #:user.Address{:street "200 N Mangum", :city "Durham", :state "NC", :zip 27702}} </code> {{ https://i.imgur.com/Ze8GvTt.jpg?400 }} {{ https://i.imgur.com/HgEP75x.jpg?400 }} {{ https://i.imgur.com/z1zg5c3.jpg }} {{ https://i.imgur.com/wRyrOXN.jpg }} ### Links - https://clojuredocs.org/clojure.core/defrecord - https://github.com/bbatsov/clojure-style-guide#custom-record-constructors-naming open/defrecord.txt Last modified: 2024/10/05 06:15by 127.0.0.1