Generic programming
Generic programming is a programming paradigm in which code is written without knowing the specific type, which allows the code to be executed by, and to operate on, types to be specified later in the code.
It is not a new concept in Kotlin. Java developers are probably quite familiar with generics and generic programming. In Kotlin, while some of the rules are slightly different, many of the same concepts apply. Much of the Kotlin standard library is built using generics. Collections are a great example of this. Functions for iterating, filtering, and mapping collection values are all written using generic code so they can be applied to collections of any type.
This code snippet is taken from the Kotlin standard library: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access