<commit_before>---
type: doc
layout: reference
title: "Operator overloading"
category: "Syntax"
---

# Operator overloading

Kotlin allows us to provide implementations for a predefined set of operators on our types. These operators have fixed symbolic representation
(like `+` or `*`) and fixed [precedence](grammar.html#precedence). To implement an operator, we provide a [member function](functions.html#member-functions)
or an [extension function](extensions.html) with a fixed name, for the corresponding type, i.e. left-hand side type for binary operations and argument type for unary ones.
Functions that overload operators need to be marked with the `operator` modifier.<commit_msg>fix: broken hash link in Operator overloading (#1291)<commit_after>---
type: doc
layout: reference
title: "Operator overloading"
category: "Syntax"
---

# Operator overloading

Kotlin allows us to provide implementations for a predefined set of operators on our types. These operators have fixed symbolic representation
(like `+` or `*`) and fixed [precedence](grammar.html#expressions). To implement an operator, we provide a [member function](functions.html#member-functions)
or an [extension function](extensions.html) with a fixed name, for the corresponding type, i.e. left-hand side type for binary operations and argument type for unary ones.
Functions that overload operators need to be marked with the `operator` modifier.
{'fraction_non_alphanumeric': 0.08163265306122448, 'fraction_numerical': 0.0028149190710767065, 'mean_word_length': 5.463636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7649830', 'n_tokens_mistral': 363, 'n_tokens_neox': 342, 'n_words': 174}