2020-05-21 01:51:57 +03:00
|
|
|
// Functions inputs in leo are pass-by-value.
|
|
|
|
//
|
|
|
|
// Program execution:
|
|
|
|
// line 15: variable `a` is defined with value `1`.
|
|
|
|
// line 16: value `1` is copied and passed into function `bad_mutate()`.
|
|
|
|
// line 10: variable `x` is defined with value `1`.
|
|
|
|
// line 11: variable `x` is set to value `0`.
|
|
|
|
// line 18: program returns the value of `a`.
|
|
|
|
|
|
|
|
function bad_mutate(mut x: u32) {
|
|
|
|
x = 0; // <- does not change `a`
|
|
|
|
}
|
|
|
|
|
|
|
|
function main() -> u32 {
|
2020-06-16 19:49:45 +03:00
|
|
|
let a = 1u32;
|
2020-05-21 01:51:57 +03:00
|
|
|
bad_mutate(a);
|
|
|
|
|
|
|
|
return a // <- returns 1
|
|
|
|
}
|