【发布时间】:2020-06-29 04:58:56
【问题描述】:
我有一个用例,我想在方法调用中更新我的map 类型变量之一。这里要演示的是一段代码sn -p,
(defn func [mymap]
(conj mymap [1 2])) ;update mymap variable here such that changes are persistent after the method returns
(let [mymap {}
_ (func mymap)] (println mymap))
它输出{},因为我认为使用conj 函数创建了一个新地图。如何更新func 中的mymap 变量,使上述程序的输出为{1 2}?
如果在 Clojure 中不可能,一般如何处理此类用例?
【问题讨论】:
标签: dictionary clojure