The Kotlin language provides a set of operators which have their own symbol (for example, +, -, *, or /) and a priority defined. At the time of compilation, the Kotlin compiler transforms them into associated function calls or even more complex statements. We are also able to override an operator and declare its custom underlying implementation for a specified type. This implementation would be applied to the instances of the specified type the operator was used with.
In this recipe, we are going to define a class called Position, representing the current coordinates of the point in a three-dimensional space. Then, we are going to implement custom plus and minus operators for our class to provide a simple way of applying a geometric transformation to its instances. As a result, we want to be able to update the coordinates of the point represented by the...