Debian Codegraph @

examples/oper/overload_gru.ck

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