Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Excuse Me! Are you my Type?

Excuse Me! Are you my Type?

Type and sub type is an important aspect of object oriented programming. In this session we will learn about the Type and how they are used in Kotlin.

Also, we will have a look at some interesting types in Kotlin.

We will also be learning about variance and how it's applied to generic classes in Kotlin.

Avatar for Ashesh Bharadwaj

Ashesh Bharadwaj

September 29, 2019
Tweet

More Decks by Ashesh Bharadwaj

Other Decks in Programming

Transcript

  1. CLASS & OBJECT Photo by Pez González on Unsplash Photo

    by S O C I A L . C U T on Unsplash
  2. WHERE DOES THE TYPE COME FROM? class Student val x:

    Student Photo by Oliver Cole on Unsplash
  3. LISKOV SUBSTITUTION PRINCIPLE If S is a subtype of T,

    then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program
  4. THE ONE AT THE TOP Any, supertype of all types.

    val name: Any = "Shyam" val age: Any = 24 Photo by asoggetti on Unsplash
  5. I LIED TO YOU Any? is the supertype of Any

    val a: Any = 20 var b: Any? = a val x: String = "Suresh" var y: String? = x via GIPHY
  6. GENERICS Generics is a feature to utilize functions and properties

    of a class among different data type while keeping type safety in mind. class Box<T>