我有以下数据结构:

{:file #<File /foo.bar>, :resolution {:width 1280, :height 1024}}

我想写一个破坏的功能 :resolution 钥匙进入 widthheight 符号。就像是

(defn to-directory-name [{{:keys [width height]}} wallpaper]
  (str width "x" height))

像破坏性那样可能吗?

谢谢。

有帮助吗?

解决方案

您必须首先破坏:解决方案,然后获得宽度和高度:

{{:keys [width height]} :resolution}

其他提示

(defn to-directory-name [{{width :width height :height} :resolution}] 
  (str width "x" height))

为我工作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top