Operator overloading
Operator overloading is a language feature that defines type-specific behavior for predefined operators applied to user-defined types.
Kotlin in Action, 2E
Operator overloading is a language feature that assigns custom implementations to predefined operator symbols.
- How it is used
- Enables custom and adapted types to use familiar Kotlin arithmetic, collection, comparison, and iteration syntax.
- How deep it goes
- Works through `operator` declarations, function mappings, precedence, operand types, extensions, and unary increment semantics; defers broader convention details.
- Examples
- Demonstrates Point addition, scaling, negation, Char repetition, and BigDecimal increment with prefix and postfix forms.
- What you can do after
- Apply it via Kotlin `operator` functions to make supported predefined syntax work for custom or external types.
Read how Kotlin in Action, 2E explains operator overloading →
.NET in Action, Second Edition
Operator overloading is a language feature that lets a type define the behavior of an operator for its values.
- How it is used
- Makes elapsed-time calculations read naturally while supporting a stopwatch implementation.
- How deep it goes
- Defines the feature and shows its DateTime-to-TimeSpan implementation, without surveying general operator-design rules.
- Examples
- Uses stopwatch elapsed-time code, an explicit DateTime subtraction operator, and a clock-controlled restart test.
- What you can do after
- Understand how overloaded subtraction produces TimeSpan values and how clock injection makes related tests deterministic.
Read how .NET in Action, Second Edition explains operator overloading →
Related concepts
- timestampused by · A timestamp is a value representing a specific point in time, typically associated with an event, observation, or data item.
- infix functionalternative to · An infix function is a Kotlin function that can be called using infix notation with a single explicit argument between the receiver and argument.
- Gocontrasts with · Go is a statically typed, compiled, garbage-collected programming language with built-in support for concurrency.
- operator modifierconfigured by · The operator modifier is a Kotlin declaration modifier that permits a function to implement a predefined operator convention.
- stream insertion operatoruses · The C++ stream insertion operator, operator<<, writes formatted values to output streams and can be overloaded for user-defined types.
- custom operatorproduces · A custom operator is a programmer-defined operator with specified syntax and behavior, typically implemented by a function.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

