AI Features

Operator Functions

Learn how to define your own operators, which limitations Kotlin poses on such operators, and how they lead to succinct code.

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 can be seen as an extension of infix functions. Instead of a function name, operator functions instead use an operator ...

Ask