+ 5
The type inside the <> is called a generic type parameter.
Generics are important concepts in programming, and most of the modern languages have it.
A very typical example is collections. When you define a list, or set, or map, it is very useful to define also, what type of objects can be in that collection. You are not allowed to add a string to a list of integers.
If you declare the collection like this:
val numbers = listOf(1, 2, 3, 4);
Then the type would be automatically derived by the compiler as List<Int>
But you can also explicitly declare the type.
If you make a list of Any type, you can really add whatever you want in it, because Any is the common supertype of all other types.
val mixedBag: List<Any> = listOf(1, "Hi", 'c', 3.14)
https://code.sololearn.com/ca16a232A13A/?ref=app