October 2018
Intermediate to advanced
370 pages
9h 15m
English
Type inference is a mechanism in which the Kotlin compiler plays its role to find out a variable type. Kotlin will determine the data type by understanding the value assigned. It intelligently infers the type by the value and then makes the variable of the data type respectively. This technique is called type inference. In all the previous code, whether a data type is declared with val or var are examples of type inference:
val age = 25val name = "Bob"
In the preceding code, age is an integer and name is a string type variable. The type of these variables is inferred by the compiler.
Read now
Unlock full access