In Java, you're supposed to use Boolean.valueOf whenever converting a string
to a Boolean.  The constructors are useless unless you for some reason need
separate identities for Boolean objects.

On Sun, May 3, 2009 at 11:56 AM, Janico Greifenberg <j...@jgre.org> wrote:

>
> Hi,
>
> I encountered unexpected behavior of the 'if' form in clojure when using
> instances of java.lang.Boolean as the condition. I wanted to convert
> input strings to booleans and used the constructor of the Boolean class
> with the string parameter. However, when I pass these values as a
> condition to if, the true-branch always gets executed. For example:
>
>  > (if (Boolean. "true") 1 2)
> 1
>  > (if (Boolean. "false") 1 2)
> 1
>
> It seems to me that this has to do with the identity of the objects, as
> (Boolean. "false") is not identical (although equal) to the clojure
> literal false. Is this behavior intentional or a bug?
>
> The problem does not occur when I use Boolean/parseBoolean which returns
> a lower case boolean.
>
> So long
> Janico
>
> >
>

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