Skip to content
Kavachकवच

If...Else: if

● Beginner2 min

if on its own: the block runs when the condition is true, and is skipped when it isn't.

fn main() {
    const temperature = 34
    if temperature > 30 {
        print("A hot day")
    }
    print("Done")
}

The program ran and printed:

kavach run if.kav

A hot dayDone
if.kav: Kavach code, then what running it prints

Change 34 to 20 and only Done is printed.