You should always think about code wrapping to make such a conversion into a clearly defined function. This allows you to be more visual in your code, and also allows you to change the implementation, if necessary, to a later date (for example, if you identify other lines that should also be considered true).
I would suggest something like:
(defn true-string? [s]
(= s "true"))
Applying this to your test cases:
(if (true-string? "true") (println "working") (println "not working"))
=> working
(if (true-string? "false") (println "working") (println "not working"))
=> not working
source
share