A more complicated structure test.
This commit is contained in:
27
examples/basic/struct0003.ngr
Normal file
27
examples/basic/struct0003.ngr
Normal file
@@ -0,0 +1,27 @@
|
||||
struct Point {
|
||||
x: u64;
|
||||
y: u64;
|
||||
}
|
||||
|
||||
struct Line {
|
||||
start: Point;
|
||||
end: Point;
|
||||
}
|
||||
|
||||
function slope(l) -> u64
|
||||
(l.end.y - l.start.y) / (l.end.x - l.start.x);
|
||||
|
||||
test = Line {
|
||||
start: Point {
|
||||
x: 1;
|
||||
y: 2;
|
||||
};
|
||||
end: Point {
|
||||
x: 2;
|
||||
y: 4;
|
||||
};
|
||||
};
|
||||
|
||||
foo = slope(test);
|
||||
|
||||
print foo;
|
||||
Reference in New Issue
Block a user