Differentiate Nil, Null, None, and Nothing in scala.

devquora
devquora

Posted On: Feb 22, 2018

 

The difference between these four attributes in scala is given below:
  • Nil- it is used to initialize an empty list since it is an object which extends list.
  • Null- null in scala is used to provide compatibility with the java null keyword or to provide a type for the null keyword. It also represents the absence of type information for complex types.
  • None- the “none” pattern in scala is used to remove null values from the scala code.
  • Nothing- it is used for providing the return type for the operations that can affect the normal flow of program.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Scala Interview Questions

    What do you mean by a Scala map?

    The collection of key-value pairs where the key can retrieve the values present in a map is known as a scala map. The k..

    Scala Interview Questions

    List the advantages of using scala over other functional programming languages.

    Some of the advantages due to which scala is preferred over other functional programming languages are listed below: As..

    Scala Interview Questions

    Tell the advantages of companion objects when used in Scala?

    Instead of having static methods or variables, scala has singleton or companion objects. These objects are then compile..