let vs def in clojure

后端 未结 6 1776
日久生厌
日久生厌 2020-12-15 03:07

I want to make a local instance of a Java Scanner class in a clojure program. Why does this not work:

; gives me:  count not supported on this          


        
6条回答
  •  一整个雨季
    2020-12-15 03:24

    LET is not "make a lexical binding in the current scope", but "make a new lexical scope with the following bindings".

    (let [s (foo whatever)]
      ;; s is bound here
      )
    ;; but not here
    
    (def s (foo whatever))
    ;; s is bound here
    

提交回复
热议问题