Clojure def vs defn for a function with no arguments

后端 未结 4 1248
萌比男神i
萌比男神i 2021-02-01 01:19

I have written a program in clojure but some of the functions have no arguments. What would be the advantages of coding such functions as a \"def\" instead of a \"defn\" with no

4条回答
  •  迷失自我
    2021-02-01 01:48

    (def t0 (System/currentTimeMillis))
    (defn t1 [] (System/currentTimeMillis))
    (t1)
    ;; => 1318408717941
    t0
    ;; => 1318408644243
    t0
    ;; => 1318408644243
    (t1)
    ;; => 1318408719361
    

提交回复
热议问题