liveBook · Manning

Operator overloading

Operator overloading is a language feature that defines type-specific behavior for predefined operators applied to user-defined types.

How 2 Manning books explain it

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

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.