Operators: Unary, Increment, and Decrement

Learn how to work with unary operators and understand the concepts of increment and decrement operators.

Unary prefix operators

A +, -, or ! in front of a single value is also an operator. Operators that are used with only a single value are called unary operators.

Points to remember:

  • Unary operators are used with only a single value (operand).

  • Operators used with two values are known as binary operators; however, since most operators are binary, this type is often treated as the default.

  • Operators used with three values are known as ternary operators.

  • Since there is only one ternary operator in mainstream programming languages, namely the conditional operator, it is often referred to as the ternary operator.

Kotlin supports operator overloading for the following unary operators:

Get hands-on with 1200+ tech skills courses.