Skip to content
Kavachकवच

Syntax: Source files

● Beginner3 min

A statement ends at the end of its line, unless the line clearly isn't finished.

fn main() {
    const price = 40
    const total = price * 3 +
        20
    const words = ["kavach", "is", "here"]
        .map(w => w.len())
    print(total)
    print(words)
}

The program ran and printed:

kavach run statements.kav

140[6, 2, 4]
statements.kav: Kavach code, then what running it prints

A statement goes on to the next line when:

  • the line ends with an operator such as +, or with , ( [ {;
  • the next line starts with ., as in a chain of method calls.

Inside ( … ) and [ … ], line breaks never end a statement, so long lists and calls can spread over lines freely.