3

试图让一段代码看起来更好看。

我在 Clojurescript 中有以下内容:

(swap! app-state assoc-in [:lastresults] [])
(swap! app-state assoc-in [:error] false)
(swap! app-state assoc-in [:computing] true)

有时更多。关于如何将其转换为更清洁的多任务的任何想法。

我正在看类似的东西:

 (swap! app-state assoc-in
      [:lastresults] []
      [:error] false
      [:computing] true)
4

1 回答 1

7

你不需要assoc-in仅仅一个级别。这适用于您的示例:

(swap! app-state assoc 
       :lastresults [] 
       :error false 
       :computing true)
于 2014-09-30T01:33:15.187 回答