Kotlin Operators Overview


Operators Definition

In Kotlin, Operators are special symbols or characters that do some operations on variables or values. That variables or values are called as operands. which perform commonly similar functions, but which differ syntax and declaration from usual functions.

for example,

+ performs addition and returns operands added value.

a+b

here, + returns values added a and b value.

Types of Operators In Kotlin

  • Arithmetic Operators (Mathematical Operators)
  • Assignment Operators and Augmented assignment Operators
  • Unary Operators (Sign, Inverts, Increment, and Decrement)
  • Logical Operators
  • Bitwise Operators
  • Equality Operators  (==, !=) and Referential equality Operators (===, !==)
  • Comparison Operators (<, >, <=, >=)
  • In Operator
  • is and !is Operators
  • Cast Operators - Unsafe (as) and Safe (as?) cast Operators
  • Indexed access Operator [, ]
  • Invoke Operator (invoke())
  • not-null assertion Operator (!!) 
  • safe call operator (?.)
  • Elvis Operator (?:)
  • Reference Operator (::) (member reference or a class reference)
  • Range Operator (..)