From the course: Moving Your iOS App to Android Using Kotlin
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Generics
From the course: Moving Your iOS App to Android Using Kotlin
Generics
- [Instructor] Let's go ahead and dive into our generics example. First, we'll come up here and comment out this, collapse the monitor and then, let's go into our generics KT class and in here, we're going to have a few things. We'll just make our first generic. They're very similar to Swift, box<T> where T is of type T, var value = t. You've probably seen this before in Swift, it's a very powerful paradigm to work with. We'll go ahead and surround this and we'll say this is generic types. But that's how we would create a simple generic. There's a larger discussion to talk about variants, co-variants, contra-variants, in-variants, it is just a concept that works with most objects like if we chose a string, we know that a string is a descendant of object or in Kotlin, it's a descendant of any and lists of objects aren't necessarily the same as lists of strings, so you can't assign a variable of a list of object to a list of strings. It's a lot of more complex thought going into it and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Lambdas7m 12s
-
Exceptions6m 29s
-
Interfaces4m 1s
-
Interface conflicts4m 45s
-
Classes: Properties1m 44s
-
Classes: Constructors4m 12s
-
Types of classes3m 15s
-
Inheritance: Functions2m 30s
-
Inheritance: Properties2m 49s
-
Enums5m 36s
-
Generics5m 24s
-
Extension basics4m 26s
-
Extension imports2m 24s
-
Extension Collisions2m 45s
-
Working with Java: Marshalling types2m 18s
-
Working with Java: In Kotlin2m 39s
-
Working with Java: From Kotlin3m 16s
-
-
-
-
-