Is Unit a singleton?


#1

As Unit type has only one value, does it mean Unit is a singleton?


#2

Yes, it its. Keep in mind that scala.Unit object is not extending scala.Unit class. The singleton is not actually defined anywhere - exists only during compilation phase. It’s converted to scala.runtime.BoxedUnit when it’s value is needed.