Hi,

You are not in the Clojure play ground when you use (Boolean. false).

This expression creates a Java object, hence (if any-java-object ...)
always evaluate the "true" branch in Clojure.

In Clojure, anything not nil is true except false which is equivalent to the 
Java
false value.
(if false....) (if nil ...) will both evaluate the "false" branch.

In your specific case, (if (.booleanValue (Boolean. false)) ...) would correctly
evaluate since booleanValue returns the value in the object, not the
object itself.

If you can, stay in Clojure and avoid Java for a while until you get more
code lines behind you.

Hope I am clear enough, just woke up :)

Luc


> Hi,
> 
> I am using Clojure for a month now. I like it a lot so far, but there
> are a couple of little details that make me very afraid. Foremost:
> 
> (if (Boolean. false) "jesus" "christ")
> 
> will return "jesus", not "christ". Googling this on the net, I found
> that this is a known phenomenon, and some rationalizations of why this
> is the correct thing to do (it is not, sorry Rich).
> 
> I could live with this, but I have code that is written completely in
> clojure, and does not create Boolean objects in any explicit way, or
> uses third-party libraries except for the stuff in clojure.core and
> slingshot. Nevertheless, somehow Boolean objects seem to creep into
> live, and I have code like that:
> 
> (if (:leaf m-node)
>     ....
>     ...
> )
> 
> that breaks because of it. I am using from the github repository
> ( 14428c296de483ea666bd874701046e7088e545c).
> 
> This means that I cannot trust my code on the most basic level, and
> this is unacceptable.
> 
> 
> -- 
> 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
> 
--
Softaddicts<lprefonta...@softaddicts.ca> sent by ibisMail!

-- 
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

Reply via email to