Contravariance in Scala: Why Is It So Hard? | Rock the JVM

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

КОМЕНТАРІ • 61

  • @sergeikharchikov1157
    @sergeikharchikov1157 4 роки тому +30

    You definitely have a talent for explanation

  • @yohaitol
    @yohaitol 4 роки тому +11

    I have read several explanations about the variances subject and never felt like I fully understood it.
    This video is the best explanation I found, now I feel very comfortable with it.
    Thanks a lot and please make more videos like this :-)

    • @rockthejvm
      @rockthejvm  4 роки тому

      Brilliant, glad it clicked!

  • @awesomebearaudiobooks
    @awesomebearaudiobooks Рік тому +2

    Taking my fedora off to honor the humanity-changing great feat of Laika the space dog 😔🎩
    You will forever be in our hearts, comrade Laika ❤
    Let's honor her memory by studying hard, so that the people of the world can finally tame the boundless nature of outer space... With the help of Scala, obviously.

  • @_mumbler_
    @_mumbler_ 4 роки тому +8

    The best explanation of contravariance I’ve seen.

    • @rockthejvm
      @rockthejvm  4 роки тому

      That's my goal, glad it helped!

  • @jimaaman
    @jimaaman 4 роки тому +8

    Slowly coming to terms with this concept but the consumes vs. produces rule of thumb is the best summary I've seen so far of when to apply variance. 👍

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

    Finally, someone could make me understand this thing... BTW I came here without any knowledge of Scala (my background is from Kotlin lol). The way that you explained it is so good that I could understand it even with examples in a language that I had never seeing before. Thank you so much.

  •  2 роки тому +1

    This is the best explanation of this concept I have seen till now! Thanks, Daniel!

  • @Alchimystic
    @Alchimystic Рік тому +2

    An interesting natural example where variance and contravariance exist, even if doesn't seem logical: human blood types.
    In terms of blood cell compatibility, O is the universal donor (provides for every other), while AB is the universal receiver.
    In terms of plasma is the other way around: AB is the universal donor, while O is the universal receiver

  • @vetiarvind
    @vetiarvind 3 роки тому +1

    wow, underrated channel, i remember drawing a lot of diagrams explaining contravariance in stackoverflow once so i thought i understood it but you have an incredibly effective way of distilling information. i'm going to watch all your videos just to see how you explain it ==)

  • @mikepictor
    @mikepictor Рік тому +1

    Really really good explanation. It feels quite intuitive now

  • @sergeykvartalnov8232
    @sergeykvartalnov8232 2 роки тому +1

    Best Scala tutorials evere, I'm so happy I found your channe. Perfect 💯

  • @colin398
    @colin398 Рік тому +2

    I liked your examples a lot

  • @UniformDelta00
    @UniformDelta00 2 роки тому +1

    What a wonderful video, this subject was so vague for me, thank you !

  • @temoncher
    @temoncher 3 роки тому

    The best co- vs contravariance explanation in the world

  • @OmarMendozaKS
    @OmarMendozaKS 2 роки тому

    Awesome video man, quite simple, after some research I was almost at the starting point to understand this, your approach rocks, just one complaint, Hachi was not a lucky dog, he is a legend, 👏

  • @flaviodasilveirapepino6076
    @flaviodasilveirapepino6076 4 роки тому +4

    I've benn waiting for this video!

  • @welltv1142
    @welltv1142 Рік тому +1

    That was really helpful, thanks man!

  • @TJ-hs1qm
    @TJ-hs1qm 3 роки тому +1

    so awesomely explained I finally got it. Thank you!

  • @viddyasagarverma3722
    @viddyasagarverma3722 4 роки тому +1

    As always very well explained.
    Thank you.

  • @mompyish
    @mompyish 3 роки тому +1

    I read effective java to thousand articles .Contra-variance remained a puzzle.I think today it sinked in.Thanks.

  • @radool22
    @radool22 Рік тому

    The explanation makes perfect sense but couldn’t you just as easily have defined a Vet that supports a method heal of type animal? What benefit does specifying contra bring here? Covariant Vet[T

    • @rockthejvm
      @rockthejvm  Рік тому

      No, because each T is different. Variance is all about the ability to replace a Vet of a type, with a Vet of another type.

  • @rheafernandeshallu
    @rheafernandeshallu 4 роки тому +2

    Thanks a lot :). I learnt something completely new today

  • @mourikogoro9709
    @mourikogoro9709 4 роки тому +3

    A god-send video!

  • @MrCesarification
    @MrCesarification Рік тому +1

    Wonderful stuff

  • @philipkononenko4942
    @philipkononenko4942 3 роки тому +1

    Thanks for the video! Great explanation

  • @XeonFGT
    @XeonFGT 3 роки тому

    Excellent explanation!

  • @mohamadbilal54
    @mohamadbilal54 4 роки тому +1

    Thank you very much, it's very valuable

  • @SuperSam4y0u
    @SuperSam4y0u 4 роки тому +1

    Very helpful, thankyou so much!

  • @RajeshSamson
    @RajeshSamson 3 роки тому

    I guess no one in UA-cam will explain as you do🤩🤩

  • @ColibrisMusicLive
    @ColibrisMusicLive 2 роки тому

    could you give an example why would one need
    vet: Vet[Dog] and not vet: Vet[Animal]?

    • @rockthejvm
      @rockthejvm  2 роки тому

      It's the same problem in OOP - why would you specifically need a Dog when you can program against the Animal interface?
      With contravariance, it's the same question, in reverse.

  • @puraniksaket
    @puraniksaket 4 роки тому +2

    amazing

  • @slisnychyi
    @slisnychyi 3 роки тому

    really best explanation

  • @YouTikki
    @YouTikki 4 роки тому +1

    Thank you sir :)

  • @erkanaslanel8084
    @erkanaslanel8084 3 роки тому +2

    God bless you :)

  • @slack128
    @slack128 4 роки тому +1

    The link no longer works.

  • @hgfuhgvg
    @hgfuhgvg 4 роки тому

    ua-cam.com/video/b1ftkK1zhxI/v-deo.html maybe better to clarify that the type List is COVARIANT (and not the type Animal)

  • @hgfuhgvg
    @hgfuhgvg 4 роки тому +1

    I wish I could give more likes

  • @jewelleharper6285
    @jewelleharper6285 2 роки тому

    Great Videos,
    however... I would most definitely not call it "Lucky" or fortunate to be Lakia to die of asphyxiation and overheating... Also Hachi is an incredibly sad movie...

  • @OK-iw5im
    @OK-iw5im 3 місяці тому +1

    incredible thank you

  • @DiegoFerreiradaSilva
    @DiegoFerreiradaSilva 4 роки тому +1

    amazing