【发布时间】:2021-10-03 01:27:47
【问题描述】:
为什么case 在使用记录类型时不起作用?
(defrecord Thing [x])
=> myproject.core.Thing
(defn foo [x]
(case (type x)
Thing "Thing found!"
"nope!"))
=> #'myproject.core/foo
(foo (Thing. 123))
=> "nope!"
为什么这不起作用?直接测试相等性似乎有效:
(= (type (Thing. 123)) Thing)
=> true
【问题讨论】:
标签: clojure