2
有沒有辦法通過實現IDeref在cljs中創建另一個容器?如何在clojurescript中創建IDerefable?
(reify clojure.lang.IDeref
(deref [_] ...))
編譯器警告IDeref是不是一種協議
有沒有辦法通過實現IDeref在cljs中創建另一個容器?如何在clojurescript中創建IDerefable?
(reify clojure.lang.IDeref
(deref [_] ...))
編譯器警告IDeref是不是一種協議
試試這個: 「你好!」
(def a
(reify IDeref
(-deref [_] "Hello!")))
(.log js/console @a)
輸出。您可能想要使用deftype:
(deftype LikeAtom []
IDeref
(-deref [_] "Hello!"))
(.log js/console @(LikeAtom.))
謝謝,作品! – Frawr