Control Flow (if, for, while)
Nubo supports common control flow constructs to manage the flow of your programs.
If Statement
Section titled “If Statement”if condition { // code when true} else { // code when false}
Example:
let age = 20if age >= 18 { println("Adult")} else { println("Minor")}
For loop
Section titled “For loop”Iterate over ranges or collections.
Using range:
Section titled “Using range:”for i in range(0, 5) { println(i)}
Using a list:
Section titled “Using a list:”let fruits = ["apple", "banana", "cherry"]for fruit in fruits { println(fruit)}
While Loop
Section titled “While Loop”Loop while condition is true:
let count = 0while count < 3 { println(count) count = count + 1}