[Project_owners] Mixing conditional operators and new Boolean

Neil neil at parkwaycc.co.uk
Tue Feb 19 16:51:32 PST 2008


Jesper Staun Hansen wrote:

> I was just wondering if this would even work for all:
> var Private = (!Clan && !Group && !Admin)? new Boolean(true) : new 
> Boolean(false);
>
> Would the new Boolean(true) be passed to Private or would I error by 
> design here?
> Does it work for all new something.

Assuming this is JavaScript, then it isn't typed, and it will let you 
write foo ? atan(1) * 4 : "?" if you really want.

Note that your example is really bad as you would never use ?: to choose 
between true and false, you would always write new Boolean(!Clan && 
!Group && !Admin) (assuming you really want a Boolean) instead.


More information about the Project_owners mailing list