Boolean values: Difference between revisions

Expanded answer to include examples, and some information about other boolean-like quantities.
(Expanded details about boolean values with examples, and included a brief mention about `yes` and `no` AppleScript constants.)
(Expanded answer to include examples, and some information about other boolean-like quantities.)
Line 122:
true = 1 --> false</lang>
 
AppleScript also has constants <code>yes</code> and <code>no</code>, which coerce easily to boolean values,. and They have little practical value in AppleScript except if one wishes to use them as arguments in place of boolean values for novelty's sake. They are interchangeable with themboolean values as parameters in AppleScriptObjC (not demonstrated here).
 
<lang AppleScript>{yes as boolean, no as boolean}
--> {true, false}</lang>
 
However, <code>yes</code> and <code>no</code> do not coerce to integer values.
 
Finally, AppleScript also includes keywords <code>with</code> and <code>without</code>, used in declaring parameters for and sending parameters of boolean nature to handlers. They are synonymous with <code>true</code> and <code>false</code>, respectively, and the compiler will sometimes perform the substitution at compile time.
 
<lang AppleScript>sortItems from L given reversal : true</lang>
 
gets compiled immediately to become:
 
<lang AppleScript>sortItems from L with reversal</lang>
 
However, the equivalent call to the handler utilising <code>yes</code>, whilst accepted readily in place of its boolean counterpart, is left alone by the compiler:
 
<lang AppleScript>sortItems from L given reversal:yes</lang>
 
=={{header|Applesoft BASIC}}==
Anonymous user