|
From: Steve Y. <st...@ca...> - 2001-07-14 19:33:37
|
Thanks!!
-steve
Kevin Butler writes:
> Steve Yegge wrote:
>
> > I've found a case where it doesn't work:
> >
> > from java.lang import Boolean
> > ...
> > obj.setProperty("foobar", Boolean.FALSE)
> >
> > I also tried:
> >
> > obj.setProperty("foobar", 0)
> >
> > but that somehow turns 0 into an int value and uses that,
> > where I really wanted a boolean.
> >
>
> I didn't see a public answer for this question, so here goes.
>
> >>> from java.lang import *
> >>> from java.util import *
> >>> m = HashMap()
> >>> m.put( "one", Boolean.FALSE )
> >>> m.put( "two", Boolean( 0 ) )
> >>> m
> {two=false, one=0}
> >>>
>
> The problem is that jython converts the Boolean.FALSE to an 'int' for
> you to work with in jython (normal attribute access, etc.). To pass in
> a Boolean object, you need to explicitly specify it via constructing one
> as your parameter.
>
> >>> Boolean.FALSE
> 0
> >>> Boolean( Boolean.FALSE )
> false
> >>>
>
> kb
>
|