Debian Codegraph @

src/test/01-Basic/205-op-overload-gru.ck

raw
1 // test gruck (graphical chuck) operator
2
3 // a class
4 class Thing { float x; }
5
6 // overload gruck operator
7 fun Thing @operator -->( Thing lhs, Thing rhs )
8 {
9 <<< lhs.x, rhs.x >>>;
10 return rhs;
11 }
12
13 // set up a few Things
14 Thing foo; 1 => foo.x;
15 Thing bar; 2 => bar.x;
16 Thing zaz; 3 => zaz.x;
17
18 // gruck foo to bar
19 foo --> bar;
20
21 // gruck foo to bar to zaz
22 foo --> bar --> zaz;
23
24 // (should have printed some stuff)