Clojure call the returned function

One sentence summary: () is the clojure execution function, not eval or apply, the test code is as follows

(defn enforce-api-key []
  (fn [x]
   (println x)
   (if (= "key" x)
		(println "===")
		(println "xxx")
		)
	)
)

((enforce-api-key ) "k")

 ((enforce-api-key ) "key")

or

 (defn enforce-api-key [x]
  (fn []
   (println x)
   (if (= "key" x)
		(println "===")
		(println "xxx")
		)
	)
)
(enforce-api-key  "k")
((enforce-api-key  "k"))

 ((enforce-api-key   "key"))

Guess you like

Origin blog.csdn.net/weixin_40455124/article/details/114503681