noir by example

enums

currently, there’s no official enum support in the language

however, a submodule with globals can kinda compensate

mod OrderType {
    global FULL_OPEN: Field = 0;
    global PARTIAL_OPEN: Field = 1;
    global FULL_RESTRICTED: Field = 2;
    global PARTIAL_RESTRICTED: Field = 3;
    global CONTRACT: Field = 4;
}

fn main(order_type: Field) {
    assert(order_type != OrderType::FULL_OPEN);
}

#[test]
fn test_main() {
    main(OrderType::PARTIAL_OPEN);
}

try it out install the noir toolchain if you haven't yet:
        curl -L https://noirup.org/install | bash
        noirup --nightly
        
then checkout and run the example:
        git clone https://github.com/sambarnes/noir-by-example.git
        cd noir-by-example/circuits/examples/enums
        nargo test --show-output
        

prev (higher order functions) next (optional / nullish variables)