operators

Operator Overloading in Kotlin

What is operator overloading? Operator overloading has its root in the language C++. It means, that you can define the behavior if an operator (e.g. +, -, *, …) is applied to your type. (Wikipedia ) In C++ this looks like the following. Given we have a class Vector containing a x and a y field as coordinates. We can define the operator plus + as follows: Vector operator + (Vector const &obj) { Vector res; res.

Weiterlesen