0 votes
in Scala Constructs by
Explain the difference between the terms Nil, Null, None and Nothing.

1 Answer

0 votes
by

Null, null, Nil, Nothing, None, and Unit are all used to represent empty values in Scala.   

  1. Null refers to the absence of data, and its type is Null with a capital N.  
  2. Null is considered to be a list that contains zero items. Essentially, it indicates the end of the list.  
  3. Nothing is also a trait without instances.   
  4. None represents a sensible return value. 
  5. Unit is the return type for functions that return no value. 
...