Skip to content

Features Control Statements

Kameron Brooks edited this page Aug 17, 2019 · 1 revision

Control Statements

If/Else

// if
if(x == 1) {
   //...
}

// if else
if(x == 1) {
   //...
} else {
   //...
}

// if else if else
if(x == 1) {
   //...
} else if(x == 2) {
   //...
} else {
   //...
}

An else statement can technically be followed by a different statement, which could allow interesting things like:

if(arr == null) {
   print("arr is null");
} else for(int i = 0; i < arr.length; i += 1) {
   print("array element!");
}

While

while(true) {
    //...
}

Do-While

Not yet supported


For

for(int i = 0; i < x; i += 1) {
   //...
}

Foreach/For-In/For-of

Not supported