可以通过与结构对象一起访问键来访问结构的各个字段。

Accessing Individual - 语法

:key structure-name

参数      -  "key"是结构中的键值, "structure-name"是作为相应关键字的结构。

返回值  -  将返回与键关联的值。以下程序显示了有关如何使用它的示例。

Accessing Individual - 示例

(ns clojure.examples.example
   (:gen-class))
(defn Example []
   (defstruct Employee :EmployeeName :Employeeid)
   (def emp (struct-map Employee :EmployeeName "Learnfk" :Employeeid 1))
   (println (:Employeeid emp))
   (println (:EmployeeName emp)))
(Example)

上面的程序产生以下输出。

1
Learnfk

参考链接

https://www.learnfk.com/clojure/clojure-accessing-individual-fields.html