polserver/testsuite/escript/classes/doc-sample-04.src
Kevin Eady 0988c17f29 Add classes documentation (#717)
* Add escript guide docs for classes

* Add ClassInstanceRef to objref docs

* Use objref.dot to generate svg
2024-10-10 18:06:04 +02:00

21 lines
436 B
Text

class Colorable()
function Colorable( this, color )
this.color := color;
endfunction
endclass
class Drawable()
function Drawable( this, x, y )
this.x := x;
this.y := y;
endfunction
endclass
class Shape( Colorable, Drawable )
function Shape( this, color, x, y )
super( color, x, y );
endfunction
endclass
var shape := Shape( "red", 1, 2 );
print( $"{shape.color} {shape.x} {shape.y}" ); // Output: red 1 2