So you want to be a Kotlin programmer?

You’ve come to the right place!

This series will take you through the fundamentals of Kotlin, gently introducing you to the core concepts of the language, in order to help you become a proficient Kotlin developer. Even if you’re a seasoned pro, it’s important to know the fundamentals in order to establish a solid foundation of understanding, so that you can be as effective as possible.

Your adventure starts here in Chapter 1, where we’ll cover the basics of variables, expressions, and types.

Let’s get to it!

Introduction to Variables

This is a circle.

Thousands of years ago, a Greek fellow named Archimedes roughly figured out how to measure the length of the outside of a circle, called the circumference. You probably remember the equation the good old days of junior high school:

“The circumference of a circle is equal to 2 times π times the radius of the circle”.

In the equation above, the letter r isn’t a number itself. It’s a letter that represents the radius - a number that measures the distance between the center of the circle and the edge of the circle.

We call r a variable, because the radius can vary, depending on the size of the circle. In other words, the variable r isn’t a number itself; it’s just sort of a “bucket” that holds a number - any number.

Variables aren’t just for algebra and geometry. They’re also used all the time in programming, where they serve the same purpose: holding values. In Kotlin, you can create a variable and put a number into it like this: