Polyglot CheatSheet - None/Null/Nil

Updated: 2018-05-28

Java

null

Scala

  • Null: a Trait.
  • null: an instance of Null
  • Nil: an empty List of anything of zero length. It refers to List which has no contents(not "refers to nothing")
  • Nothing: a Trait; a subtype of everything; not superclass of anything; no instances of Nothing.
  • None: a sensible return value to avoid null pointer exception. One of 2 subclasses of Option, the other is Some.
  • Unit– Type of method that doesn’t return a value of any sort.

Javascript

  • undefined
  • null

Ruby

nil

Python

None