Boo has operator overloading. Overloaded operators must be defin=
ed as **static**. For example:

=20

struct myNum: =09i as double =09def constructor(j as int): =09=09i =3D j =09static def op_Multiply(x as myNum, j as int): =09=09x.i =3D x.i * j =09=09return x =09static def op_Multiply(x as myNum, y as myNum): =09=09x.i =3D x.i * y.i =09=09return x =09static def op_Addition(x as myNum, j as int): =09=09x.i =3D x.i + j =09=09return x =09static def op_Equality(x as myNum, y as double): =09=09return x.i =3D=3D y =09static def op_UnaryNegation(x as myNum): =09=09x.i =3D -x.i =09=09return x =09def ToString(): =09=09return i.ToString() x =3D myNum(5) y =3D -x*x*2 + 1 assert y =3D=3D -49=20

These binary operators can be overloaded:

=20=20

op_Addition op_Subtraction op_Multiply op_Division op_Modulus op_Exponentiation op_Equality op_LessThan op_LessThanOrEqual op_GreaterThan op_GreaterThanOrEqual op_Match op_NotMatch op_Member op_NotMember op_BitwiseOr op_BitwiseAnd=20

When you overload a binary arithmetic operator such as op_Addition, the = corresponding assignment operator ( +=3D ) is overloaded too.

=20This unary operator can be overloaded:

=20=20

op_UnaryNegation=20