NPR puzzle

Brian Yennie briany at qldlearning.com
Thu Jul 21 23:43:43 EDT 2005


> However... you're pulling a fast one here. You're getting away with
> calling something a boolean when it actually isn't. Apparently
> Transcript is letting you get away with this.
>
> "if tSymbolArray[char 1 to 2 of tWord] then"    should really be
> "if tSymbolArray[char 1 to 2 of tWord] is not empty then"

Well, to be fair, even a strongly-typed language like C lets you do the 
same sort of things.
false is frequently defined as "everything other than true".

if/else is usually interpreted as "if TRUE then do this, OTHERWISE do 
this", not "if TRUE then do this, if FALSE do this".

In C, you get things like:

if (0)...
if ('') ...
if (NULL)...

etc... which all evaluate to false.

Of course when speed is not critical, it's easier to read if you say 
things like:

"if (condition = TRUE)"    instead of    "if (condition)"

As such the point is well taken, but I think it's actually accepted 
practice in most languages to do the latter.

- Brian




More information about the use-livecode mailing list