The Difference Between Null, Nothing, Nil, None and Unit in Scala | Rock the JVM

Поділитися
Вставка
  • Опубліковано 26 вер 2024

КОМЕНТАРІ • 18

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

    I've been programming in scala for 4 years and finally decided I better get to the bottom of these types 😂 this is awesome and so clear!! Thank you!!!!

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

    Your scala videos are the best

  • @randallwalkerdiaz1002
    @randallwalkerdiaz1002 4 роки тому +5

    Wow, overwhelmed with 5 types of nothing haha.

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

      The good news is that you don't really need to use them when writing your own Scala code, except for None when you work with Options, and maybe Unit, although that can be inferred most of the time.

  • @yodaman115
    @yodaman115 2 роки тому +2

    Totally missed the opportunity to make a punny reference to Sum 41

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

    Very nice video, I think what is missing (maybe) are uses cases, when do we need to use Null, Nothing.

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

      Null and Nothing are almost never used by themselves, they are the type of null and error-throwing respectively, as we show in the video.

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

    Very helpful.
    Would be a great addition is you showed some usecases for them which I guess is very challenging for some :D

  • @pavelb.9483
    @pavelb.9483 3 роки тому +1

    Good lesson, thanks

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

    Very nice..

  • @nifaresg
    @nifaresg 11 місяців тому

    is scala api null proof? i mean will i have to deal with it when writing my code? why they introduced it when we have Option...

    • @rockthejvm
      @rockthejvm  11 місяців тому

      Just use Options!

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

      I think null pretty much has to exist due to Java interop. The alternative would be Kotlin's solution: having duplicates of every single type in order to specify if the value can be null or not.

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

      There are actually other reasons to use nulls. Because scala 3 has really cool features such as union types, it's possible to use union types of SomeType | Null, that allows significantly reduce memory usage.