Boolean values: Difference between revisions

Add Ecstasy example
(fixing the syntaxhighlight tag in the Rockstar section I just added)
(Add Ecstasy example)
Line 906:
(not 0) → #f
</syntaxhighlight>
 
=={{header|Ecstasy}}==
Ecstasy's defines [https://github.com/xtclang/xvm/blob/master/lib_ecstasy/src/main/x/ecstasy/Boolean.x an enumeration named Boolean], which contains the values <span style="background-color: #e5e4e2"><tt>&nbsp;False&nbsp;</tt></span> and <span style="background-color: #e5e4e2"><tt>&nbsp;True&nbsp;</tt></span>.
<syntaxhighlight lang="java">
module GeorgeBoole
{
@Inject Console console;
 
void run()
{
Boolean f = False;
assert !f == True;
 
// methods like "and", "or", "xor", and "not" are the same as
// the operators "&"/"&&", "|"/"||", "^"/"^^", and the unary "~"
assert True.and(False) == True & False == False;
assert True.or(False) == True | False == True;
assert True.xor(False) == True ^ False == True;
assert True.not() == ~True == False;
 
console.println($"0==1 = {0==1}");
console.println($"!False = {!False}");
}
}
</syntaxhighlight>
 
Output:
<syntaxhighlight>
0==1 = False
!False = True
</syntaxhighlight>
 
=={{header|EGL}}==
In EGL boolean is a primitive type, however it acts the same as an integer (type int). A boolean and an int accept integer values aswel as true and false keywords (which represent resp. 1 and 0). A boolean is always true except when it has value 0 (or keyword false).
162

edits