Jump to content

Boolean values: Difference between revisions

Line 413:
{{header|Sather}}
Sather uses the <code>BOOL</code> class which can be <code>true</code> or <code>false</code>. In Sather there's no implicit conversion between types, so numeric values can't be used to mean true or false.
 
=={{header|Sather}}==
The BOOL type can be <code>true</code> or <code>false</code>. Sather never implicitly does casting of a type in another, so numeric value or other types cannot be used (implicitly) as boolean value; nonetheless an explicit "cast" can be done:
 
<lang sather>v:BOOL := true; -- ok
i:INT := 1;
v := 1; -- wrong
if i then ... end; -- wrong: if requires a bool!
-- BUT
v := 1.bool; -- ok
if i.bool then ... end; -- ok</lang>
 
In this case, <code>0.bool</code> is false, and <code>n.bool</code> with n not equal to 0 is true.
 
=={{header|Scala}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.