【问题标题】:What's the meaning of #inst "2000" and the concept behind it in (clojrue.spec/inst-in #inst "2000" #inst "2010")#inst "2000" 的含义是什么及其背后的概念(clojrue.spec/inst-in #inst "2000" #inst "2010")
【发布时间】:2016-06-10 08:37:53
【问题描述】:

我正在研究clojure.spec,遇到以下情况:

(s/def ::the-aughts (s/inst-in #inst "2000" #inst "2010"))

我猜#inst "2000" 可能意味着 2000 年初的一个时间实例。但我无法通过 google 找到描述该符号及其背后概念的正确文档。

我也没有在我的 Clojure 教科书中学习过。

【问题讨论】:

    标签: clojure clojure.spec


    【解决方案1】:

    此语法称为"tagged literals"。它允许使用您自己的类型扩展EDNClojure reader supports it 并提供了一种将标签文字映射到将产生实际值的函数的机制。

    即时标记文字 (#inst) 映射到 date parsed from the string。您可以在the cookbookClojure changelog 中找到更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多