相关疑难解决方法(0)

Clojure:"java.lang.IllegalArgumentException:没有为key提供值:"当我更改require时

我正在使用java.lang.IllegalArgumentException: No value supplied for key:我的Clojure代码.

我知道当我试图在作为参数传递的映射中对密钥进行解构时会发生这种情况.

然而,奇怪的是,这个函数已经很好地工作了很长时间,具有相同的数据.唯一似乎不同的是我现在如何导入该功能

这是错误:

Caused by: java.lang.IllegalArgumentException: No value supplied for key: 
{:style {:color [255 150 150 255], :stroke-weight 2}, :points [[-1 0] [0 -1] [1 0] [0 1] [-1 0]]}
Run Code Online (Sandbox Code Playgroud)

而这就是抛出它的功能.

(defn scale
  [val {:keys [style points]}]
  {:style style
   :points (scale-shape val points)})
Run Code Online (Sandbox Code Playgroud)

换句话说,我要求地图包含被调用的键style,points并且它被赋予一个包含被称为style和的键的映射points.

这段代码已经好几个月了.

不同之处在于我现在使用导入的sshapes/scale位置调用它sshapes:

 (:require [patterning.sshapes :as sshapes])
Run Code Online (Sandbox Code Playgroud)

而之前我只是把它称为scale使用扩展名进入命名空间的地方

 (:require [patterning.sshapes :refer :all])
Run Code Online (Sandbox Code Playgroud)

这会导致那种错误吗?

clojure require destructuring

4
推荐指数
1
解决办法
4449
查看次数

标签 统计

clojure ×1

destructuring ×1

require ×1