Alpha. Vary is under active development and not ready for production use. Syntax, APIs, performance, and behaviour may change between releases.

Collections

Three built-in collection types. All are generic and mutable. See Collections and strings for methods.

let nums: List[Int] = [1, 2, 3]
let ages: Dict[Str, Int] = {"Alice": 30, "Bob": 25}
mut seen: Set[Int] = {1, 2, 3}

Lists support indexing and slicing (nums[0], nums[1:3]). Dicts support key access (ages["Alice"]). Sets support operators (a | b, a & b).

Collection literals, tuples, and function calls can span multiple lines with trailing commas:

let items = [
    "alpha",
    "beta",
    "gamma",
]

Comprehensions

let squares = [x * x for x in range(10)]
let evens = [x for x in range(20) if x % 2 == 0]
let unique = {x % 5 for x in range(20)}
let lookup = {str(i): i * i for i in range(5)}

Each comprehension allows one for clause and an optional if filter.