All the extension functions for collections that allow us to work with collections in a functional style are defined as inline functions. That means their bodies are generated in the byte code instead of function calls. Another thing that we can notice looking at declarations is that these functions return new collections. For instance, a filter creates a new collection that contains the result and returns it. how do I calculate how many collections are created? Example: How many collections are created while running the code below?
val list = listOf(1, 2, 3)
val maxOddSquare = list
.map{it * it}
.filter{it % 2 == 1}
.max()