Scala Language Operator Overloading


Example

In Scala you can define your own operators:

class Team {
   def +(member: Person) = ...
}

With the above defines you can use it like:

ITTeam + Jack

or

ITTeam.+(Jack)

To define unary operators you can prefix it with unary_. E.g. unary_!

class MyBigInt {
   def unary_! = ...
}

var a: MyBigInt = new MyBigInt
var b = !a