Very basic question… Could you please tell me what is the most idiomatic way to bind var to a specified value when it is bound to
nil or any other incorrect value?
In case of
nil the simplest way I came with is
(let [y (if y y 123)] ...), like this:
(defn just-for-test [x y] (let [y (if y y (get-some-data))] ; do something with x and y (println x y) ))
Of course, the wrong value doesn’t have to be
nil. It could be for example empty collection which would look like
(let [y (if (seq y) y [:a :b :c])] ...).
The reason I’m asking is that the code
y (if y y 123] looks funny so I’m not sure if it’s just me being unexperienced and the code is OK