5
我看到了Clojure的功能爲什麼參數[i]
包括在括號中被定義爲Clojure的`在括號defn`參數或不
(defn toInt([i] (Integer. i)))
?這和下面一樣嗎?有什麼區別?
(defn toInt [i] (Integer. i))
我看到了Clojure的功能爲什麼參數[i]
包括在括號中被定義爲Clojure的`在括號defn`參數或不
(defn toInt([i] (Integer. i)))
?這和下面一樣嗎?有什麼區別?
(defn toInt [i] (Integer. i))
第一個使用符號重載的符號,但只包含一個arity。
實施例具有兩個arities:
(defn my-add
([x] (+ x 1))
([x y] (+ x y)))
(my-add 1) ;;=> 2
(my-add 1 2) ;;=> 3
另見http://clojure.org/functional_programming(搜索元數超載)。