当我意外地将函数返回的列表传递给 update-in
而不是向量时,这个让我感到困惑。
示例
`
some-app.core=> (update-in [:a :b :c] [1] name)
[:a "b" :c]
some-app.core=> (update-in '(:a :b :c) [1] name)
NullPointerException clojure.core/name (core.clj:1518)
`
如果传递了另一个函数,也会得到类似的结果;例如
`
some-app.core=> (update-in ["a" "b" "c"] [1] str/capitalize)
["a" "B" "c"]
some-app.core=> (update-in '("a" "b" "c") [1] str/capitalize)
NullPointerException clojure.string/capitalize (string.clj:199)
`