Your function expects two parameters (has arity 2.) The first parameter's name is _
(underscore,) which conventionally denotes a variable which is not used. (It is a valid variable name, and it becomes bound, but by convention it is not used, so it denotes a placeholder.)
The second parameter is destructured - {:keys [kind]}
, which means that the expected value is a map, and as a result of destructuring a variable named kind
will be bound to the value of key :kind
of the actual parameter (or nil if there is no such key.)
So your function expects two parameters, the first is ignored, the second must be a map with a key :kind
(maybe other keys as well, but they are ignored.)
((fn [_ {:keys [kind]}] kind) :foo {:kind :bar, :color :green})
=> :bar
P.S. I have looked at your question again, and I realised where your confusion may be coming from. The syntax [_ {:kind [kind]}]
looks like a vector that includes a map at the second position. That's correct, but not everywhere in Clojure a vector notation means you can stick a vector there. Clojure users square brackets for a list of formal parameters of a function - it is part of a common pattern in Clojure of using vector literals everywhere a sequence may be expected. It is in fact very convenient, compared to other Lisps where you need to carefully use quotes in many places to avoid interpreting your lists as function application forms. But that's a digression, the important point is in fn
(and defn
) the square brackets denote parameter list and do not mean that the parameter is a vector.