Internally, computers represent everything as a number. But they can still store and process all kinds of information—from simple numbers to photos to music to the entire human genome. You'll learn more about how they can do that as you go along.
In Kotlin, as long as we provide an initial value when we declare a variable the compiler can usually guess—or infer—what the type is. The variable still has a type, and Kotlin will make sure that we don't change its type later. Assigning a type to each variable help us write more correct programs. For example, it doesn't make sense to try and add a boolean value (true or false) to an integer value (1, 2, etc.). But, unlike some other languages, in Kotlin we don't always need to provide an explicit type.
Let's get practice working with some of Kotlin's simplest or primitive data types. Write a snippet of code—not a function— that:
var
) count
of type Int
and initializes it to 88temperature
of type Double
and initializes it to 14.3letter
of type Char
and initializes it to XisCSAwesome
of type Boolean
and initializes it to true