相关疑难解决方法(0)

什么类型的功能?

让我们尝试一些对"类型"函数的调用:

user=> (type 10)
java.lang.Integer

user=> (type 10.0)
java.lang.Double

user=> (type :keyword?)
clojure.lang.Keyword
Run Code Online (Sandbox Code Playgroud)

现在有一个匿名函数:

user=> (type #(str "wonder" "what" "this" "is"))
user$eval7$fn__8
Run Code Online (Sandbox Code Playgroud)

A)这意味着"user $ eval7 $ fn__8"是什么意思? B)什么类型的功能?

"类型"的来源是:

user=> (source type)
(defn type
  "Returns the :type metadata of x, or its Class if none"
  {:added "1.0"}
  [x]
  (or (:type (meta x)) (class x)))
nil
Run Code Online (Sandbox Code Playgroud)

所以函数需要具有元数据的特定部分或者是类

检查匿名函数的元产生nada:

user=> (meta #(str "wonder" "what" "this" "is"))
nil
Run Code Online (Sandbox Code Playgroud)

尝试不同的方法:

user=> (defn woot [] (str "wonder" "what" "this" "is"))
#'user/woot
user=> (meta …
Run Code Online (Sandbox Code Playgroud)

types clojure

18
推荐指数
3
解决办法
1843
查看次数

标签 统计

clojure ×1

types ×1