small medium large xlarge

16 Jun 2012, 13:20
Jan-Paul Bultmann (1 post)

I think that instead of doing,

(defn non-blank? [line] (if (re-find #"\S" line) true false))​

a more appropriate solution would be.

(defn non-blank? [line] (boolean (re-find #"\S" line)))

It introduces a new function but prevents newcomers from thinking that (if foo true false) is acceptable style (I personally get cold shivers when reading code like this ;) )

22 May 2017, 16:14
Alex Miller (12 posts)

Thanks! In 3rd edition, we’ll actually use (not (clojure.string/blank? line)) here.

You must be logged in to comment