Operator Functions
Explore how to implement Kotlin operator functions to customize common symbols like plus, minus, times, and more for your own types. Understand operator notations including infix, prefix, and postfix to write clearer and more expressive Kotlin code.
We'll cover the following...
We'll cover the following...
Operator functions allow you to define the meaning of well-known symbols such as + and - for your own types.
Introducing Operators
Kotlin’s operators allow calling functions using certain symbols. For instance, the infix + operator actually calls a plus function so that a + b translates to a.plus(b) under the hood.
Many operators use infix notation and therefore ...