小编noi*_*ith的帖子

Clojure交换原子与地图值

我想将assoc地图的值添加到atom.我可以这样做:

  (defonce config (atom {}))
  (swap! config assoc :a "Aaa")
  (swap! config assoc :b "Bbb")
Run Code Online (Sandbox Code Playgroud)

但这是重复的,并拨打了几个电话swap!.我想做那样的事情:

(swap! config assoc  {:a "Aaa"
                      :b "Bbb"})
;; this doesn't work :
;; Exception in thread "main" clojure.lang.ArityException: Wrong number of args (2) passed to: core$assoc
Run Code Online (Sandbox Code Playgroud)

我怎么做 ?

atomic clojure

3
推荐指数
1
解决办法
2319
查看次数

标签 统计

atomic ×1

clojure ×1