Boolean values: Difference between revisions
Content deleted Content added
Added Neko |
|||
Line 1,163: | Line 1,163: | ||
Newer implementations of the language may also support !! (exclusve or). |
Newer implementations of the language may also support !! (exclusve or). |
||
There is one unary boolean operator: ' (not).</p> |
There is one unary boolean operator: ' (not).</p> |
||
=={{header|Neko}}== |
|||
Neko includes a bool boolean data type, true and false. Conditional execution flow only reacts to bool, numeric values test as false as are string literals. |
|||
Neko also includes two low level builtins: $not(value) and $istrue(value). These return bool results. $not returning true if value |
|||
is false, 0 or null. $istrue returning true if value is not false, not 0 and not null. |
|||
<lang neko>/* boolean values */ |
|||
$print(true, "\n"); |
|||
$print(false, "\n"); |
|||
if 0 { |
|||
$print("literal 0 tests true\n"); |
|||
} else { |
|||
$print("literal 0 tests false\n"); |
|||
} |
|||
if 1 { |
|||
$print("literal 1 tests true\n"); |
|||
} else { |
|||
$print("literal 1 tests false\n"); |
|||
} |
|||
if $istrue(0) { |
|||
$print("$istrue(0) tests true\n"); |
|||
} else { |
|||
$print("$istrue(0) tests false\n"); |
|||
} |
|||
if $istrue(1) { |
|||
$print("$istrue(1) tests true\n"); |
|||
} else { |
|||
$print("$istrue(1) tests false\n"); |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
prompt$ nekoc boolean.neko |
|||
prompt$ neko boolean |
|||
true |
|||
false |
|||
literal 0 tests false |
|||
literal 1 tests false |
|||
$istrue(0) tests false |
|||
$istrue(1) tests true</pre> |
|||
=={{header|Nemerle}}== |
=={{header|Nemerle}}== |