[英]Clojurescript Swap! and multiple assoc-in
Trying to make a piece of code better looking. 试图让一段代码更好看。
I have the following in Clojurescript: 我在Clojurescript中有以下内容:
(swap! app-state assoc-in [:lastresults] [])
(swap! app-state assoc-in [:error] false)
(swap! app-state assoc-in [:computing] true)
Sometimes more. 有时更多。 Any idea on how to turn this in a cleaner multi-assignment.
关于如何在更清晰的多任务中改变这一点的任何想法。
I am looking at something like: 我看的是:
(swap! app-state assoc-in
[:lastresults] []
[:error] false
[:computing] true)
You don't need assoc-in
for just one level. 您不需要只有一个级别的
assoc-in
。 This would work for your example: 这适用于您的示例:
(swap! app-state assoc
:lastresults []
:error false
:computing true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.