Book Image

Programming Kotlin

Book Image

Programming Kotlin

Overview of this book

Quickly learn the fundamentals of the Kotlin language and see it in action on the web. Easy to follow and covering the full set of programming features, this book will get you fluent in Kotlin for Android.
Table of Contents (20 chapters)
Programming Kotlin
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Chapter 8. Generics

Generics, or generic programming, is a technique whereby functions can be written in terms of types that are not specified when the function is written, and then later used for many different types. Generics is the term used in Java and Kotlin, but other names, such as parametric polymorphism and templates, are used in other languages for similar features.

In this chapter we will cover:

  • Type parameterization

  • Type bounds and recursive type bounds

  • Invariance, covariance and contravariance

  • Algebraic data types