Debian Codegraph @

src/test/07-Imports/.deps/Foo.ck

raw
1 // let's say we define a custom class...
2 public class Foo { int num; }
3
4 // persistent operator overloading (transcends file contexts)
5 // NOTE the use of 'public' instead of 'fun' -- it's fun for all!
6 // define binary operator overload for '+'
7 public Foo @operator +( Foo lhs, Foo rhs )
8 { Foo retval; lhs.num + rhs.num => retval.num; return retval; }
9
10 // LOCAL binary operator overload for '=>' (local to this context)
11 fun void @operator =^( Foo lhs, Foo rhs )
12 { <<< lhs.num, "=^", rhs.num >>>; }
13