Post

Boolean Literal

The boolean basic type has only two values; boolean true is written as true and boolean false is written as false.

✍ Syntax

true | false

Ballerina doesn’t support 0, 1 or any other variations of true or false words as alternative syntax.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import ballerina/io;

public function main() {

    boolean enable = true;
    boolean open = false;

    io:println(enable);
    io:println(open);
}
true
false
 bal version
Ballerina 2201.6.0 (Swan Lake Update 6)
// Partial Code. Change View  to see full code.
public function main() {
    boolean enable = true;
    boolean open = false;
}
// Highlights Only. Change View  to see full code.
boolean enable = true;
boolean open = false;

Code Breakdown

  • Line 5: boolean literal true is assigned to the variable enable.
  • Line 6: boolean literal false is assigned to the variable open.
 January 1, 2023

Table of Content

Key Words

Boolean Literal
 January 1, 2023

Table of Content

Key Words


Navigation

Site Settings

Site Theme

Source Code Density