codecamp

Clojure Maps keys

返回映射中的键列表。

语法

以下是语法。

(keys hmap)

参数 - 'hmap'是哈希键和值的映射。

返回值 - 返回映射中的键列表。

例子

以下是Clojure中的key的例子。

(ns clojure.examples.example
   (:gen-class))
(defn example []
   (def demokeys (hash-map "z" "1" "b" "2" "a" "3"))
   (println (keys demokeys)))
(example)

输出

上述代码输出以下结果。

(z a b)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定