Boolean conditions in Jade

For questions and postings not covered by the other forums
timmeh
Posts: 18
Joined: Fri Apr 13, 2012 3:12 pm

Boolean conditions in Jade

Postby timmeh » Mon Apr 14, 2014 4:04 pm

Just a simple one, just curious why the following logic occurs this way

Code: Select all

write "" = null; //true write "".Date = null; //true write "".TimeStamp = null; //true write "".Time = null; //false??? write "false".Boolean = null; //true?? write "true".Boolean = null; //false

Code: Select all

write "".Time = null;
If a null string typecast to a date or timestamp is equal to null why is it a time type is not while all are primaries?

Code: Select all

"false".Boolean = null;
Secondly why does the string "false" equal to null while it is not a null string?

Curious as to what is the reasoning behind this as it seems different compared to other programming languages and a bit misleading.

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: Boolean conditions in Jade

Postby murray » Mon Apr 14, 2014 7:31 pm

Regarding Booleans...
A null Boolean has the default value of false.
So, null.Boolean = false.

In your example you are typecasting a string to a Boolean. In this case the string "false" converts to the Boolean vale of false. Most variables in Jade are automaticially initialised to a default state of null, typecast to the relevant type. Dates and Times are exceptions.
Murray (N.Z.)


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests

cron