Learn Kotlin: Basic Operators

Deddy Romnan Rumapea
2 min readFeb 18, 2021
Some of the many basic operators in Kotlin

Mathematical operations like addition, substraction, multiplication, and division comes built-in with Kotlin.

However there are more available basic operators we can use to perform operations on variables and values. Learning these operators is important as you will do operations on variable and values a lot.

In the example below, we use the + operator to add together two values, a variable with a value, and a variable with another variable.

Addition operator example

We will learn four different categories of operators : arithmetic, assignment, comparison, and logical. You can use all four of them for operations of two values, a variable with a value, and a variable with another variable just like the addition operator example above.

1. Arithmetic operators

— are used to perform common mathematical operations.

Kotlin arithmetic operators
Arithmetic operators in action

2. Assignment operators

— are used to assign values to variables.

We use the assignment operator (=) to assign a value to a variable.

For example : val x = 10

We assign the value 10 to a variable named x.

Here is a list of all assignment operators:

Kotlin assignment operators list

3. Comparison operators

— are used to compare two values and will return boolean (true or false).

Kotlin comparison operators

4. Logical operators

— are used to determine the logic between variables or values and will return boolean (true or false).

Kotlin logical operators

That’s basically it. That’s all you need to know about Kotlin basic operators. You can save this article for your future reference. Thank you so much for reading. If you like these articles, let me know in the comment section below. You can also give suggestion, I’m open for any kind of feedback.

— Learn Kotlin Series —

  1. Learn Kotlin: Introduction
  2. Learn Kotlin: Hello World!
  3. Learn Kotlin: Variables
  4. Learn Kotlin: Data Types
  5. Learn Kotlin: Basic Operators (this article)
  6. Learn Kotlin: Functions

--

--