noir by example


store data in variables with the let keyword

if you need to change that data, it must be marked “mutable” with mut

fn main() {
    let immutable_var = 17;
    // immutable_var = 38;  <-- fails to compile

    // but this is legal:
    let mut mutable_var = immutable_var;
    mutable_var = 38;

    assert(mutable_var != immutable_var);

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/variables
        nargo test --show-output

prev (assert) next (functions)