noir by example


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);

fn test_main() {

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

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