Next: , Previous: Object creation, Up: Syntax


3.1.4 Method calls and dereferencing

Unlike in other languages, there is a syntactic difference between dereferencing an object and calling a method on an object. The dot (.) operator dereferences a class and returns the contents:

     x = class.property;

The pipe (|), on the other hand, dereferences the method and then calls it with the arguments and object given:

     x|doWork();

Any arguments passed to the method are within the parenthesis (which are optional if no arguments are being passed). For methods not defined in a class, the parenthesis are required for Kite to determine whether you want the method object or to call the method.

Inside of a class, if you wish to call the version of a function that is inside a parent class, you may do so by prepending the parent class's name. For example:

     class a [
         method x() [ ... ]
     ];
     
     class b from a [
         method x() [ ...; a|x(); ... ]
     ];
     
     y = make b();
     y|x;

The special __construct__ method can also be used to reference parent (or your own) constructors.