Syntax
● Beginner4 minBefore this: Your First ProgramSpec 1.1
How a Kavach file is written: one statement per line, blocks in braces, no semicolons.
fn main() {
greet("Asha")
greet("Ravi")
}
fn greet(name: String) {
print("Hello, {name}")
}The program ran and printed:
kavach run main.kav
Hello, AshaHello, Ravi
The rules in short
- A file ends in
.kav. A program starts atfn main(). - One statement per line. There are no semicolons.
- Braces
{ }group lines into a block: the body of a function, a loop or anif. - Text goes in double quotes; a single character in single quotes.
- Indent with four spaces.
kavach fmtdoes it for you.
Kavach is case-sensitive: total and Total are two different names.