Skip to content
Kavachकवच

Sets: Adding and checking

● Beginner2 min

contains asks whether a value is in the set; a loop visits the values in insertion order.

fn main() {
    const tags = Set.of("new", "sale", "gift")
    for t in tags {
        print(t)
    }
    print(tags.contains("sale"))
}

The program ran and printed:

kavach run walk.kav

newsalegifttrue
walk.kav: Kavach code, then what running it prints