01_user_documentation:07_rgg_xl:02_xl:09_java_addition:overload_operator
This is an old revision of the document!
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) { public static A operator+ (A a, int b) { a.len += b; return a; } public void operator++(){ ++this.len; } } public void run () { A a1 = new A(); println( ~a1 ); // print true println( a1 + 1 ); // print a1 with a slightly bigger len ++a1; // increases a1.len by 1 }
Overloaded operators
01_user_documentation/07_rgg_xl/02_xl/09_java_addition/overload_operator.1774623263.txt.gz ยท Last modified: 2026/03/27 15:54 by Tim
