mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Format testsuite escript * Format testsuite pol * Update docs Switch "attributes" to "members" to better align with Escript terms. * Add core-changes, breaking-changes
25 lines
564 B
Text
25 lines
564 B
Text
class Animal()
|
|
var animal_count := 0;
|
|
|
|
function Animal( this, type )
|
|
this.type := type;
|
|
this.id := ++animal_count;
|
|
endfunction
|
|
|
|
function Print( this )
|
|
basicio::Print( $"Animal {this.id} is a {this.type}" );
|
|
endfunction
|
|
endclass
|
|
|
|
var dog := Animal( "dog" );
|
|
print( dog.id ); // Output: 1
|
|
|
|
dog.Print(); // Output: Animal 1 is a dog
|
|
Animal::Print( dog ); // Output: Animal 1 is a dog
|
|
|
|
print( Animal::animal_count); // Output: 1
|
|
|
|
var cat := Animal( "cat" );
|
|
cat.Print(); // Output: Animal 2 is a cat
|
|
|
|
// print( animal_count ); // Compiler error!
|