A result type of Unit indicates the function returns no interesting
value. Scala’s Unit type is similar to Java’s void type, and in fact every
void-returning method in Java is mapped to a Unit-returning method in
Scala.
Methods with the result type of Unit, therefore, are only executed for
their side effects.
value. Scala’s Unit type is similar to Java’s void type, and in fact every
void-returning method in Java is mapped to a Unit-returning method in
Scala.
Methods with the result type of Unit, therefore, are only executed for
their side effects.