small medium large xlarge

Generic-user-small
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 ;) )

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

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

You must be logged in to comment