Search code examples
scalahierarchytype-systems

Why's type lattice in Scala?


I heard someone said:

"Scala uses a type lattice rather than a type hierarchy, which is different from Java".

I do not quite understand what the meaning type lattice is and what the main difference between type lattice and type hierarchy is.

Could someone explain this term to me?


Solution

  • Its essentially means that : The type hierarchy for Scala is a lattice, i.e. it has a “bottom” as well as a “top”.

    enter image description here

    As seen from the image the top type here is Any and the bottom is Nothing.