Free YouTube views likes and subscribers? Easily!
Get Free YouTube Subscribers, Views and Likes

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

Follow
Rock the JVM

Written version: https://blog.rockthejvm.com/nullnoth...

This video is for the beginner Scala programmer who comes from another language and might be confused about the different way of expressing the lack of a value. By the end of this video, you'll understand the difference between the null reference, the Null type, Nil, None, Unit and Nothing and will know which is used when. In short:

1. The null reference is used as an absent value when you access fields or methods you'll get the famous NullPointerException
2. The Null type is the type of the null reference.
3. Nil is the empty List.
4. None is the empty Option.
5. Unit represents "void" from other languages.
6. Nothing is the bottom of the type hierarchy.

We talk more about Nothing on video and on the blog:
   • Much Ado about Nothing | Rock the JVM  
https://rockthejvm.com/blog'>https://rockthejvm.com/blog/muchado...

Take the free Scala at Light Speed downloadable 2hour course:
https://rockthejvm.com/p/scalaatlig...

Follow Rock the JVM on:
LinkedIn:   / rockthejvm  
Twitter:   / rockthejvm  
Blog: https://rockthejvm.com/blog'>https://rockthejvm.com/blog


Home: https://rockthejvm.com


Contents:
0:00 intro
1:12 the null reference
2:16 the Null type
5:09 Nil
6:48 None
9:08 Unit
10:50 Nothing

posted by mahashumu82