Skip to content
Kavachकवच

Strings: Making strings

● Beginner3 min

Plain strings, multi-line strings in triple quotes, and raw strings that take every character as written.

fn main() {
    const poem = """
        Roses are red,
          violets are blue
        """
    print(poem)
    print(r"C:\users\{name}")
    print("Tab:\tdone")
    print("She said \"hi\"")
}

The program ran and printed:

kavach run make.kav

Roses are red,  violets are blueC:\users\{name}Tab:	doneShe said "hi"
make.kav: Kavach code, then what running it prints
  • """ … """ holds several lines. The indentation they share is removed, so the text can sit neatly in your code.
  • r"…" is raw: a backslash or a brace is just a character. Handy for Windows paths.
  • In a plain string, \t is a tab, \n a new line, \" a quote.