Most elegant, clean and robust way to update protocol state?

I want to update the protocol state by passing the state to the permission. I can’t seem to do this using match but I can with if else, does anyone know a more elegant way to do this rather than this if else idiom?

Illustrative code:

protocol[admin] Stub() {
     initial state one;
     state two;

    // Doesn't work unfortunately :( 
    permission[admin] changeState1(s: Stub.States) {
        match(s) {
            one -> become one
            two -> become two
        };
    };

    permission[admin] changeState2(s: Stub.States) {
        if (s == Stub.States.one) {
            become one
        } else if (s == Stub.States.two) {
            become two
        };
    };
};

Hi Stuart, it seems like you can do this if you surround the become with braces

    permission[admin] changeState1(s: Stub.States) {
        match(s) {
            one -> { become one }
            two -> { become two }
        };
    };
1 Like

Although it would be nicer if you could do this:

permission[admin] changeState1(s: Stub.States) {
    become s;
};