Literals are values of variables that cannot be changed after definition.
There are five types of literals in D programming:
In this shot, we will focus on the boolean literal.
Boolean literals convey the boolean logic, which means that there are two boolean literals:
True
should not be assumed to have the value 1 and false
should not be assumed to have the value 0. These boolean literals are the same as the standard D keywords true
and false
.
import std.stdio;bool boolval = true;int main(){writeln(boolval);return 0;}
Line 2: We define a boolean variable called boolval
.
Line 6: Inside the main
function, we print the value that boolval
contains, which is true
.