Closed AjaniBilby closed 3 years ago
import "print.uv";
struct Person {
id: int;
age: float;
}
fn init(): Person {
let p = Blank#[Person]();
p.age = 21.0;
p.id = 0;
return p;
}
fn age(pp: @Person) {
pp.age = pp.age + 1.0;
let b = true;
if (b) {
pp.id = 23;
}
return;
}
fn print(p: Person) {
print("Person { id: ");
print(p.id);
print(", age: ");
print(p.age);
println(" }");
return;
}
fn main(): int {
let p = init();
print( $p ); // Person { id: 0, age: 21 }
let dup = $p;
age(@dup);
print( dup ); // Person { id: 23, age: 22 }
print( p ); // Person { id: 0, age: 21 }
return 0;
}