Coding active
Coding active

Reputation: 1680

Clojure - map values

I'm trying get a clojure function to detect if the value passed is a map. For example,

user=> (if-map {:foo 1}) ;Should return true
true 
user=> (if-map "hello") ;Returns false
false

Is there a pre-built function serving this already?

Upvotes: 3

Views: 661

Answers (1)

Mark Fisher
Mark Fisher

Reputation: 9886

Yes, map? is the inbuilt function

(map? {:a 1})
=> true

(map? [1])
=> false

Upvotes: 6

Related Questions