Debian Codegraph @

src/test/01-Basic/272-this-call-ctor.ck

raw
1 // test calling constructor using `this`
2
3 class Foo
4 {
5 int theX;
6
7 // a constructor
8 fun Foo( int x ) { x => theX; }
9
10 // another constructor
11 fun Foo()
12 {
13 // call a specific constructor
14 this( 5 );
15 }
16 }
17
18 // make a foo
19 Foo foo;
20
21 // should print 5
22 if( foo.theX == 5 ) <<< "success" >>>;
23