在Clojure中访问嵌套地图值的方法?

时间:2019-09-10 10:12:16

标签: clojure clojurescript

我当前正在使用以下两个代码块来访问ClojureScript中的嵌套值:

Level1
Level2
  (def response (re-frame/subscribe [::subs/quote]))
  (def body (:body @response))
  (def value (:value body))
  (println value)

是否有更好/更简洁的方法?谢谢。

1 个答案:

答案 0 :(得分:2)

键可用作操作符来检索其值,如下所示:

(def lol (:value (:body @(re-frame/subscribe [::subs/quote]))))
(println lol)

但是,我更喜欢将函数用作get-in

的详细方式