June 2018
Intermediate to advanced
310 pages
6h 32m
English
One of the key concepts of functional programming is immutability. It means that from the moment the function receives input to the moment the function returns output, the object doesn't change. How could it change, you wonder? Let's see a simple example:
fun <T> printAndClear(list: MutableList<T>) { for (e in list) { println(e) list.remove(e) }}printAndClear(mutableListOf("a", "b", "c"))
The output would be first "a", then we'll receive ConcurrentModificationException.
Wouldn't it be great if we could protect ourselves from such runtime exceptions in the first place?
Read now
Unlock full access