Scala Tutorial - Scala Unit type








The Unit type is used to define a function that doesn't return data. It is similiar to the void keyword in Java.

Example

The following code defines a Main Method with Unit Type.

def main(args: Array[String]) : Unit = { 
} 

The Unit literal is an empty pair of parentheses, ().