Debian Codegraph @

src/test/01-Basic/208-op-overload-binary-mix.ck

raw
1 // test binary overloading on objects that return primitives
2
3 // our example class
4 public class Foo
5 { 3 => int n; }
6
7 // unary pre overloading, takes Foo returns int
8 fun int @operator +(Foo a, Foo b)
9 {
10 return a.n + b.n;
11 }
12
13 // make foo
14 Foo a, b;
15 // invoke operator overloading
16 if( a + b == 6 ) <<< "success" >>>;