Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / examples v0.1.0-demo.2

    Lookup by key

    Lookup by key

    Run from the repository or distribution root. Put xen on PATH, or substitute ./bin/xen.

    Terminal window
    xen check examples/hashmap.xen
    xen run examples/hashmap.xen
    3
    2
    hashmap.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    use std.hashmap as hashmap;
    #![explc]
    fn main() {
    let mut prices = hashmap.new<Int>();
    prices.insert("tea", 3);
    prices.insert("coffee", 4);
    let key = "tea";
    println(match prices.get_cloned(&key) {
    Option.Some(price) => price,
    Option.None => 0,
    });
    println(prices.len());
    }

    Download file

    Terminal window
    xen build examples/hashmap.xen -o app

    Run the generated executable on a compatible Linux machine.