Variance... without Generics!

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 60

  • @typealias
    @typealias  10 місяців тому +14

    Big thanks to the folks who joined the premiere and said hello in chat! Maybe we can do that again next time. I'm also considering whether an occasional livestream would be helpful, where I might be able to respond to chat questions and comments in video instead of text. Anyway, if you've got thoughts about any of that, let me know!

  • @Mike-er2ih
    @Mike-er2ih 10 місяців тому +33

    I do not know how you do it Dave but you explain everything so clear. I guess its what they call a teaching talent!

    • @typealias
      @typealias  10 місяців тому +1

      Haha, thanks so much, Mike! I do enjoy the challenge!

  • @JentaroYusong
    @JentaroYusong 10 місяців тому +13

    I loved this episode! Always had trouble with the nomenclature. Using a non-generic example is really helpful, thank you!

    • @typealias
      @typealias  10 місяців тому +1

      Thanks so much, Jentaro! Yes, some of the concepts seem a bit counterintuitive at first, but I'm glad this was helpful!

  • @randoman1212
    @randoman1212 9 місяців тому +5

    Best explanation on this topic I've seen. Great work!

    • @typealias
      @typealias  9 місяців тому

      Hey, wow! Thank you so much!

  •  10 місяців тому +4

    Thanks youtube for recommend this channel. It definitely deserve more views! You teach as clear as day, even though I'm not a native english speaker. Thanks for sharing your knowledge.

    • @typealias
      @typealias  10 місяців тому +1

      Thank you so much! I'm especially happy to hear that it's helpful for someone who doesn't natively speak English!

  • @mohammad-rezaei2018
    @mohammad-rezaei2018 6 місяців тому +1

    That is why they say teaching is an art, and how beautifully you share this art

    • @typealias
      @typealias  6 місяців тому +2

      Wow, that's very kind of you to say! Thank you so much!

  • @holonaut
    @holonaut 3 місяці тому

    Awesome! I'm learning Scala rather than Kotlin right now, but this idea of "return types can become more specific, parameter types can become more general" is a principle that applies logically to uphold contracts.

  • @dilin1947
    @dilin1947 6 місяців тому +2

    It takes a very deep understanding of a subject and a creative mind to bring such simplicity to a somewhat complex concept, in a lucid manner.
    Thank you.

  • @robkeazor9709
    @robkeazor9709 10 місяців тому +2

    Bro , the way you explained thus was flawless. Thanks

    • @typealias
      @typealias  10 місяців тому

      Haha, thank you! I'm glad you liked it!

  • @gekylafas
    @gekylafas 10 місяців тому +1

    One of the best explanations of variance I have seen/read! Thanks!

    • @typealias
      @typealias  10 місяців тому +1

      You're most welcome! I'm glad you liked it!

  • @olivierm6425
    @olivierm6425 10 місяців тому +1

    Your online book and videos are great and useful. Cannot recommend enough. Thank you sir!

    • @typealias
      @typealias  10 місяців тому

      Thank you so much - I'm so glad you've found them useful!

  • @husammuala
    @husammuala 10 місяців тому +1

    Thank you so much! Clean explanation and straight to the point. Please continue uploading videos

    • @typealias
      @typealias  10 місяців тому +1

      Thanks so much! I'll keep at it!

  • @СергейУсачев-м8г
    @СергейУсачев-м8г 8 місяців тому

    This is the best explanation I ever heard! Please dont stop doing your lessons. Also want to say thank you for your book, this is really perfect!

    • @typealias
      @typealias  8 місяців тому

      Thank you so much! I'm so glad to hear that you've enjoyed the videos and book! I'll keep at it! 👍

  • @asadullahilyas
    @asadullahilyas 6 місяців тому

    This is one of the brilliant videos on UA-cam. Mind blowing explanation. Thank you Dave. You are doing an excellent job. Keep it up.

    • @typealias
      @typealias  6 місяців тому

      Thank you so much, Asadullah! I'm glad you liked it. I'll keep at it!

  • @nasimnajand9697
    @nasimnajand9697 6 місяців тому

    This is so awesome that you explain in the most simple way. Thank you in advance 🙏

    • @typealias
      @typealias  6 місяців тому

      You're most welcome! I'm glad you enjoyed it!

  • @AntonioLeivaCom
    @AntonioLeivaCom 10 місяців тому

    I love your videos! I’m always struggling to understand and retain in my brain these to concepts, and this one will help a lot!

    • @typealias
      @typealias  10 місяців тому +1

      Antonio! Thanks so much! Yes, variance can certainly seem counterintuitive, so I've often had to think twice about it, too. Glad you enjoyed the video!

  • @avalagum7957
    @avalagum7957 10 місяців тому

    OMG! Today I understand a bit about covariance and contravariance. Thank you so much.

    • @typealias
      @typealias  10 місяців тому

      I'm so glad it was helpful! And you're most welcome!

  • @funkypopper
    @funkypopper 10 місяців тому +1

    Thank you for your video. I had misunderstood before watching your video that variance was only relevant to generics, but that was incorrect.

    • @typealias
      @typealias  10 місяців тому

      You're most welcome! I'm glad you found it helpful!

  • @sevbanthebuyer
    @sevbanthebuyer 10 місяців тому

    Great ! Very comprehensive, thank you for your effort.

    • @typealias
      @typealias  10 місяців тому

      You're most welcome!

  • @L4szcZ
    @L4szcZ 10 місяців тому

    amazing work, you don't even know how much I apprecaite your content!

    • @typealias
      @typealias  10 місяців тому +1

      Thank you so much! I'm so glad to hear you've enjoyed it!

  • @darwincordova8241
    @darwincordova8241 9 місяців тому

    Man, your explanation is great!

    • @typealias
      @typealias  9 місяців тому

      Thanks so much, Darwin! I'm glad you liked it!

  • @khouari1
    @khouari1 9 місяців тому

    Very nice, high quality, video! Thanks!

    • @typealias
      @typealias  9 місяців тому

      You're most welcome! I'm glad you liked it!

  • @gunishjain9307
    @gunishjain9307 Місяць тому

    Great Explanation!

  • @Alchemist10241
    @Alchemist10241 10 місяців тому +1

    I never completely know in and out keywords, Now I totally get it, well don

    • @typealias
      @typealias  10 місяців тому

      Thank you so much! I'm glad you found it helpful!

  • @vasilemoraru89
    @vasilemoraru89 9 місяців тому

    Very well explained !!!

  • @lp1926.guitars
    @lp1926.guitars 9 місяців тому

    You're very good at this 👏

    • @typealias
      @typealias  9 місяців тому +1

      Hey, thank you so much!

  • @MikeMcCartney
    @MikeMcCartney 10 місяців тому

    Great video, but I'd like to know a bit more about why params should be contravariant and why that isn't considered 'breaking the contract'.

    • @typealias
      @typealias  10 місяців тому

      Hey Mike, sure thing!
      Let's say you've got a birthday card that you want to send to your friend. You need to find an envelope receptacle to mail it (i.e., a collection box that accepts envelopes). In this case, the contract you need is that _the receptacle must accept an envelope_. A thin mail slot at an apartment complex would meet your needs - it fulfills the contract, because it accepts an envelope.
      Now, if you were to go to the post office, they might have a receptacle that's big enough to receive either an envelope _or_ a box package - any kind of mail. That receptacle would _also_ meet your needs, because it still accepts an envelope. Sure, it also happens to accept packages, but that fact is irrelevant to your situation - as long as it accepts an envelope, it meets the contract.
      Similarly, in Kotlin, you could assign the post office mail receptacle to a variable that's declared as an envelope receptacle, because it can still accept envelopes.
      ---
      interface Mail
      interface Envelope : Mail
      interface Package : Mail
      val mailSlot: (Envelope) -> Unit = { /* ... */ }
      val postOffice: (Mail) -> Unit = { /* ... */ }
      var envelopeReceptacle: (Envelope) -> Unit
      envelopeReceptacle = mailSlot // OK - accepts envelopes
      envelopeReceptacle = postOffice // OK - also still accepts envelopes
      ---
      Does that example help to clarify it better?

    • @MikeMcCartney
      @MikeMcCartney 10 місяців тому

      Thanks @@typealias , I understand the examples but it's also easy to think up examples where this doesn't make sense. You could change the parameter type in the implementation to "Any". Very useful video though - many thanks!

    • @typealias
      @typealias  10 місяців тому +2

      Okay, thanks Mike! If you want, feel free to direct-message me on X or LinkedIn, and I can send you early access to Chapter 19, and see if you still have unanswered questions after reading it. (I'm sure if you'd have some questions, other people would, too!)

  • @ruivo_dev
    @ruivo_dev 10 місяців тому

    Great content, thanks!

    • @typealias
      @typealias  10 місяців тому +1

      You're most welcome! I'm glad you liked it!

  • @shriharshabhagwat6289
    @shriharshabhagwat6289 7 місяців тому

    Talent in Teaching ✅

  • @Jason-o5s
    @Jason-o5s Місяць тому

    Cheer~~~the fact or quality of being different, divergent, or inconsistent.😊

  • @srikrishnanunna1
    @srikrishnanunna1 9 місяців тому

    Now I am more confused, but some level of knowledge is acquired. Maybe we need some kind of mnemonics with images to understand it more.

    • @srikrishnanunna1
      @srikrishnanunna1 9 місяців тому

      I will try to watch the entire video 3-4 times and write notes on it to better understand it.

    • @typealias
      @typealias  9 місяців тому +2

      Wow, watching the video multiple times and taking notes - that's dedication! 👏 The concepts in this video might make more sense for you when chapter 19 comes out, so if it's still not connecting for you after a few times through, don't worry too much!

    • @srikrishnanunna1
      @srikrishnanunna1 9 місяців тому +1

      @@typealias Took 4 more times to rewatch the entire video and understood a lot!
      Understanding Variance without generics did help to understand how Variance with Generics works!
      Very nicely explained! Thanks.