Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Idiomatic way to get one of possible values in a map?

Tags:

clojure

What is the best way to get the first non nil value of several possible keys in a map.

Example:

(get-first-matching {:fum 4 :bar 41 :baz 45} [:foo :bar :baz])
;=> 41
like image 992
AnnanFay Avatar asked Jan 09 '12 15:01

AnnanFay


1 Answers

some.

user=> (some {:fum 4 :bar 41 :baz 45} [:foo :bar :baz])
41
like image 153
Jonas Avatar answered Sep 20 '22 10:09

Jonas