You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Maciej Zywno <m....@gmail.com> on 2007/06/15 00:25:25 UTC
toBooleanDefaultIfNull - why (bool.booleanValue() ? true : false)
Hey,
I wanted to use BooleanUtils.toBooleanDefaultIfNull method however I can see
that it returns with:
return (bool.booleanValue() ? true : false);
Shouldn't it be just:
return bool.booleanValue()
?
Wouldn't it be faster the second way? Or is there any idea behind the way
it's implemented right now? Sorry if it's obvious, but I was just curious :)
Thanks,
Maciek
Re: toBooleanDefaultIfNull - why (bool.booleanValue() ? true : false)
Posted by Henri Yandell <fl...@gmail.com>.
On 6/14/07, Maciej Zywno <m....@gmail.com> wrote:
> Hey,
>
> I wanted to use BooleanUtils.toBooleanDefaultIfNull method however I can see
> that it returns with:
>
> return (bool.booleanValue() ? true : false);
>
> Shouldn't it be just:
>
> return bool.booleanValue()
>
> ?
>
> Wouldn't it be faster the second way? Or is there any idea behind the way
> it's implemented right now? Sorry if it's obvious, but I was just curious :)
No idea why it's that way - personally I'd do:
return (bool.booleanValue() == true);
and then lower down:
return (bool.booleanValue() == false);
Looking through the BooleanUtils class... I'm wondering if it really
has much value as a class. A lot of very obvious bits of code that
don't save a lot.
Hen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org