i've never seen a "new Boolean(...)" in my 10 years of developing java code.
Am 07.04.2012 22:49, schrieb Michael Klishin: > Steven Obua: > >> (if (Boolean. false) "jesus" "christ") >> >> will return "jesus", not "christ". Googling this on the net, I found >> that this is a known phenomenon > > http://docs.oracle.com/javase/7/docs/api/java/lang/Boolean.html#Boolean(boolean) > says: > > «Note: It is rarely appropriate to use this constructor. Unless a new > instance is required, the static factory valueOf(boolean) is generally a > better choice.» > > Now lets take a look at some of the alternative choices: > > user=> (if (Boolean/valueOf true) "true" "false") > "true" > user=> (if (Boolean/valueOf false) "true" "false") > "false" > user=> (if (Boolean/valueOf "false") "true" "false") > "false" > user=> (if (Boolean/valueOf "true") "true" "false") > "true" > user=> (if (Boolean/TRUE) "true" "false") > "true" > user=> (if (Boolean/FALSE) "true" "false") > "false" > user=> (if false "true" "false") > "false" > user=> (if true "true" "false") > "true" > > So, what does all this mean? > > 1. This is not a Clojure behavior but a Java one. Somehow millions of Java > developers and projects > managed to get by with this weird behavior. > > 2. This fact is documented and there are alternatives. > > 3. You can get very far with just true and false literals, especially in pure > Clojure programs. > > MK > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en