June 2018
Intermediate to advanced
310 pages
6h 32m
English
Let's define a simple string in Java:
String s = "Hello World";
We defined that s is of type String. But why? Isn't it obvious at this point?
Kotlin provides us with type inference:
val s = "Hello World"
Now, the compiler will decide what type of variable should be used. Unlike interpreted languages (such as JavaScript, Groovy, or Ruby), the type of variable is defined only once. This will not work:
var s = "I'm a string"s = 1 // s is a String
You may wonder why we've used one var and one val to define the variables. We'll explain it shortly.
Read now
Unlock full access