The Concept of Operator Overloading

Somewhere, the programming language needs to know that / means division, and it needs to actually implement the division functionality.

Worse, the division logic may vary somewhat by data type. Dividing two integers might be handled somewhat differently than would dividing two floating-point numbers.

Some languages simply “bake in” their support for operators and their corresponding operations. Java, for example, considers operators and what they do to be part of the core language.

Other languages — such as Kotlin — support operator overloading. Simply put:

Some languages — such as Swift — take the next step and allow developers to define brand-new operators (e.g., ***), which then get treated the same as the standard operators. Kotlin does not go to that length, though.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.