Overload operator

Operators can be overloaded in XL by declaring the method operator$NAME_OF_OPERATOR(var , var ){}. The list of operators in groimp is available at: xl specification.

module A(float len) extends Sphere(0.1)
{
	public static boolean operator$com (A a) {
		return true;
	}
	public static A operator$add (A a, int b) {
		a.len += b;
		return a;
	}
}
 
public void run ()
{
	A a1 = new A();
	println(  ~a1  ); // print true
	println(  a1 + 1 ); // print a1 with a slightly bigger len
}