Module 08 of 12

Generics & Extensions

Lessons

About This Module

Generics let you write classes and functions that work with many types while staying type-safe. Instead of duplicating code for each type, you declare a type parameter such as T and the compiler checks the types for you. You've already used generics every time you wrote List<String> or Map<String, Int>.

Extensions let you add new functions and properties to existing classes without inheriting from them or changing their source code. You'll learn to write extension functions and extension properties that make your code read more naturally, and see how much of the Kotlin standard library is built from them.

Watch the lessons in order, then continue on to Coroutines.

Lessons

4 videos
01

Kotlin Generics Tutorial: Master Type Parameters for Beginners

A beginner-friendly introduction to Kotlin generics and type parameters for writing type-safe, reusable code.

02

Kotlin For Beginners (Generics: Part One)

Shows how generics are beneficial and how they can increase the reusability of your code.

03

Kotlin Extension Functions Tutorial - Add Methods to Classes Without Inheritance

Teaches how to add new methods to existing classes without modifying their source code.

04

Kotlin Extension Functions & Extension Properties

Covers how to use extension functions and extension properties in Kotlin.