Better way to nest if-let in clojure

Viewed 3761

Say I have a map of this form:

(def m {:a "A" :b "B"})

and I want to do something if :a and :b are both not nil, I can do:

(if-let [a (:a m)]
  (if-let [b (:b m)]
      ... etc ))

or

(if (and (:a m) (:b m))
  (let [{a :a b :b} m]
      ... etc ))

or even

(if (every? m [:a :b])
  (let [{a :a b :b} m]
      ... etc ))

Is there a neater (ie one-line) way to achieve this?

5 Answers
Related