Initial Commit
This commit is contained in:
706 files changed
+135430
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import std::io;
|
||||
struct point { var x: int; }
|
||||
def point::move(&mut this, by: int): void { this.x += by; }
|
||||
def grow(xs: &mut int[2]): void { xs[1] = 9; }
|
||||
def bump(p: &mut point): void { p.x++; }
|
||||
def total(xs: &int[2]): int { var t := 0; for x in xs { t += x; } return t; }
|
||||
def same<T>(x: &T): T { return x; }
|
||||
def main(): void {
|
||||
var xs := [1, 2];
|
||||
val alias := xs;
|
||||
grow(&mut xs);
|
||||
var p := point{ 1 };
|
||||
bump(p);
|
||||
p.move(same(10));
|
||||
println($"{xs} {alias} {p.x} {total(&xs)} {total(&[4, 5])} {same(true)}");
|
||||
var nested := [[1, 0], [2, 0]];
|
||||
grow(&mut nested[1]);
|
||||
println($"{nested}");
|
||||
}
|
||||
Reference in new issue
Block a user